From: Junio C Hamano <gitster@pobox.com>
To: Thomas Rast <trast@student.ethz.ch>
Cc: <git@vger.kernel.org>, Bo Yang <struggleyb.nku@gmail.com>
Subject: Re: [PATCH v7 5/5] Implement line-history search (git log -L)
Date: Thu, 07 Jun 2012 10:42:47 -0700 [thread overview]
Message-ID: <7vhaunhvc8.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <61a797a048c43d64352ef86a1b224f017e7161ae.1339063659.git.trast@student.ethz.ch> (Thomas Rast's message of "Thu, 7 Jun 2012 12:23:29 +0200")
Thomas Rast <trast@student.ethz.ch> writes:
> This is a rewrite of much of Bo's work, mainly in an effort to split
> it into smaller, easier to understand routines.
You mentioned "splitting" in the cover letter, but it does seem to
need a bit more work.
> diff --git a/builtin/log.c b/builtin/log.c
> index 906dca4..4a0d5da 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -38,6 +39,12 @@
> ...
> +static int log_line_range_callback(const struct option *option, const char *arg, int unset)
> +{
> + struct line_opt_callback_data *data = option->value;
> + struct line_log_data *r;
> + const char *name_start, *range_arg, *full_path;
> ...
> + ALLOC_GROW(r->args, r->arg_nr+1, r->arg_alloc);
> + r->args[r->arg_nr++] = range_arg;
Assignment discards qualifiers from pointer target type; this
pointer does not have to be "const char *" perhaps?
> @@ -94,15 +135,23 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
> {
> struct userformat_want w;
> int quiet = 0, source = 0;
> + static struct line_opt_callback_data line_cb = {0};
> + static int full_line_diff;
Variable unused.
> diff --git a/line.c b/line.c
> index a7f33ed..d837bb3 100644
> --- a/line.c
> +++ b/line.c
> @@ -1,6 +1,459 @@
> ...
> +static void diff_ranges_release (struct diff_ranges *diff)
> +{
> + range_set_release(&diff->parent);
> + range_set_release(&diff->target);
> +}
Unused.
> +static struct line_log_data *
> +search_line_log_data(struct line_log_data *list, const char *path)
> +{
> + return search_line_log_data_1(list, path, NULL);
> +}
Unused.
> +static void line_log_data_sort (struct line_log_data *list)
> +{
> + struct line_log_data *p = list;
> + while (p) {
> + sort_and_merge_range_set(&p->ranges);
> + p = p->next;
> + }
> +}
Unused.
> +static int ranges_overlap (struct range *a, struct range *b)
> +{
> + return !(a->end <= b->start || b->end <= a->start);
> +}
> +
> +/*
> + * Given a diff and the set of interesting ranges, determine all hunks
> + * of the diff which touch (overlap) at least one of the interesting
> + * ranges in the target.
> + */
> +static void diff_ranges_filter_touched (struct diff_ranges *out,
> + struct diff_ranges *diff,
> + struct range_set *rs)
> +{
> + int i, j = 0;
> +
> + assert(out->target.nr == 0);
> +
> + for (i = 0; i < diff->target.nr; i++) {
> + while (diff->target.ranges[i].start > rs->ranges[j].end) {
> + j++;
> + if (j == rs->nr)
> + return;
> + }
> + if (ranges_overlap(&diff->target.ranges[i], &rs->ranges[j])) {
> + range_set_append(&out->parent,
> + diff->parent.ranges[i].start,
> + diff->parent.ranges[i].end);
> + range_set_append(&out->target,
> + diff->target.ranges[i].start,
> + diff->target.ranges[i].end);
> + }
> + }
> +}
Shouldn't the ranges be merged, not just appended?
> diff --git a/log-tree.c b/log-tree.c
> index c894930..3fb025d 100644
> --- a/log-tree.c
> +++ b/log-tree.c
> @@ -809,6 +809,9 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
> log.parent = NULL;
> opt->loginfo = &log;
>
> + if (opt->line_level_traverse)
> + return line_log_print(opt, commit);
> +
#include "line.h" is missing from the beginning of this file.
> diff --git a/revision.h b/revision.h
> index 6d09550..01902cf 100644
> --- a/revision.h
> +++ b/revision.h
> @@ -92,7 +92,8 @@ struct rev_info {
> cherry_mark:1,
> bisect:1,
> ancestry_path:1,
> - first_parent_only:1;
> + first_parent_only:1,
> + line_level_traverse:1;
>
> /* Diff flags */
> unsigned int diff:1,
> @@ -168,6 +169,9 @@ struct rev_info {
> int count_left;
> int count_right;
> int count_same;
> +
> + /* line level range that we are chasing */
> + struct decoration line_log_data;
Good use of decoration.
> };
>
> #define REV_TREE_SAME 0
next prev parent reply other threads:[~2012-06-07 17:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-07 10:23 [PATCH v7 0/5] git log -L, all new and shiny Thomas Rast
2012-06-07 10:23 ` [PATCH v7 1/5] Refactor parse_loc Thomas Rast
2012-06-07 10:23 ` [PATCH v7 2/5] blame: introduce $ as "end of file" in -L syntax Thomas Rast
2012-06-07 17:23 ` Junio C Hamano
2012-06-07 17:44 ` Thomas Rast
2012-06-07 10:23 ` [PATCH v7 3/5] Export three functions from diff.c Thomas Rast
2012-06-07 17:44 ` Junio C Hamano
2012-06-07 10:23 ` [PATCH v7 4/5] Export rewrite_parents() for 'log -L' Thomas Rast
2012-06-07 10:23 ` [PATCH v7 5/5] Implement line-history search (git log -L) Thomas Rast
2012-06-07 17:42 ` Junio C Hamano [this message]
2012-06-07 17:52 ` Thomas Rast
2012-06-10 9:38 ` Zbigniew Jędrzejewski-Szmek
2012-06-15 4:40 ` [PATCH v7 0/5] git log -L, all new and shiny Junio C Hamano
2012-06-15 13:29 ` Thomas Rast
2012-06-15 15:23 ` Junio C Hamano
2012-06-16 6:01 ` Junio C Hamano
2012-06-19 10:11 ` Thomas Rast
2012-06-19 10:33 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vhaunhvc8.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=struggleyb.nku@gmail.com \
--cc=trast@student.ethz.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).