From: Thomas Rast <trast@student.ethz.ch>
To: Bo Yang <struggleyb.nku@gmail.com>
Cc: <git@vger.kernel.org>, <Jens.Lehmann@web.de>
Subject: Re: [PATCH v4 03/18] Add the basic data structure for line level history
Date: Thu, 5 Aug 2010 23:09:02 +0200 [thread overview]
Message-ID: <201008052309.03193.trast@student.ethz.ch> (raw)
In-Reply-To: <1281024717-7855-4-git-send-email-struggleyb.nku@gmail.com>
Bo Yang wrote:
> 'struct diff_line_range' is the main data structure to keep
> track of the line ranges we are currently interested in. The
> user starts digging from a line range, and after examining the
> diff that affects that range by a commit, we can find a new
> range that corresponds to this range. So, we will associate this
> new range with the commit's parent commit.
>
> There is one 'diff_line_range' for each file, and there are
> multiple 'struct range' in each 'diff_line_range'. In this way,
> we support multiple ranges.
>
> Within 'struct range', there are multiple 'struct print_range'
> which represent a diff hunk.
>
> Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
> diff --git a/line.c b/line.c
Some error messages could be improved, e.g.
> + if (obj->type != OBJ_COMMIT)
> + die("Non commit %s?", revs->pending.objects[i].name);
"'%s' is not a commit"
> + if (commit)
> + die("More than one commit to dig from: %s and %s?",
> + revs->pending.objects[i].name,
> + revs->pending.objects[found].name);
"You must specify exactly one starting commit for line history"
Showing two revisions from the command line is fairly arbitrary, what
if the user specified three? It also results in such oddness as
$ ./git-log next^@ -L 1,2 README
fatal: More than one commit to dig from: next and next?
assuming the tip of 'next' is a merge.
> + if (commit == NULL)
> + die("No commit specified?");
"You must specify a starting commit for line history"
> + if (get_tree_entry(commit->object.sha1, r->spec->path,
> + sha1, &mode))
> + goto error;
[...]
> + return;
> +error:
> + die("There is no path %s in the commit", r->spec->path);
Since die() never returns, you can move it in the place of the goto
and make Dijkstra happy.
> +/*
> + * copied from blame.c, indeed, we can even to use this to test
> + * whether line log works. :)
> + */
> +static const char *parse_loc(const char *spec, struct diff_filespec *file,
> + long lines, unsigned long *line_ends,
> + long begin, long *ret)
You immediately refactor this in the next commit, which is cute to
test the feature as indicated in the comment, but for a nicer series
please move the refactoring before this commit and just reuse the
code.
> +static void parse_range(long lines, unsigned long *line_ends,
> + struct range *r, struct diff_filespec *spec)
> +{
> + const char *term;
> +
> + term = parse_loc(r->arg, spec, lines, line_ends, 1, &r->start);
> + if (*term == ',') {
> + term = parse_loc(term + 1, spec, lines, line_ends,
> + r->start + 1, &r->end);
> + if (*term) {
> + die("-L parameter's argument should be <start>,<end>");
"-L argument must be <start>,<end>"
Though git-blame seems to imply ',$' if you do not give an end. Any
particular reason why we do not want to be compatible with blame here?
> + if (*term)
> + die("-L parameter's argument should be <start>,<end>");
See above.
> +/*
> + * Insert a new line range into a diff_line_range struct, and keep the
> + * r->ranges sorted by their starting line number.
> + */
> +struct range *diff_line_range_insert(struct diff_line_range *r, const char *arg,
> + int start, int end)
If I read the code correctly, it also ensures that no two ranges have
overlapping extents, i.e., it will merge them if they overlap.
Which leads to the question: is this a requirement for the users of
the data structure, or just an optimization? If it's a requirement,
please put this in a comment somewhere.
> + /*
> + * Note we support -M/-C to detect file rename
> + */
> + opt->nr_paths = 0;
Do we? :-)
Out of curiosity: Without looking any further, I assume this disables
the path filtering stage that you had in early versions. Did you
notice any speed hit or improvement by doing so?
> diff --git a/line.h b/line.h
[...]
> +struct range {
> + const char *arg; /* The argument to specify this line range */
> + long start, end; /* The start line number, inclusive */
> + long pstart, pend; /* The end line number, inclusive */
So 'end' is a start line number, and 'pstart' is an end line number?
You are using 'pstart' and 'pend' in other places in the header, too.
What do they mean? In line.c I inferred ptwo was "previous two", but
here it seems to be "printing start"?
--
Thomas Rast
trast@{inf,student}.ethz.ch
next prev parent reply other threads:[~2010-08-05 21:09 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-05 16:11 [PATCH v4 00/18] Reroll the line log series Bo Yang
2010-08-05 16:11 ` [PATCH v4 01/18] parse-options: enhance STOP_AT_NON_OPTION Bo Yang
2010-08-05 16:11 ` [PATCH v4 02/18] parse-options: add two helper functions Bo Yang
2010-08-05 20:43 ` Thomas Rast
2010-08-05 16:11 ` [PATCH v4 03/18] Add the basic data structure for line level history Bo Yang
2010-08-05 21:09 ` Thomas Rast [this message]
2010-08-06 19:42 ` Junio C Hamano
2010-08-05 16:11 ` [PATCH v4 04/18] Refactor parse_loc Bo Yang
2010-08-05 16:11 ` [PATCH v4 05/18] Parse the -L options Bo Yang
2010-08-06 19:42 ` Junio C Hamano
2010-08-10 15:40 ` Bo Yang
2010-08-05 16:11 ` [PATCH v4 06/18] Export three functions from diff.c Bo Yang
2010-08-05 16:11 ` [PATCH v4 07/18] Add range clone functions Bo Yang
2010-08-05 16:11 ` [PATCH v4 08/18] map/take range to the parent of commits Bo Yang
2010-08-05 21:32 ` Thomas Rast
2010-08-05 16:11 ` [PATCH v4 09/18] Print the line log Bo Yang
2010-08-05 16:11 ` [PATCH v4 10/18] Hook line history into cmd_log, ensuring a topo-ordered walk Bo Yang
2010-08-05 16:11 ` [PATCH v4 11/18] Add tests for line history browser Bo Yang
2010-08-05 20:38 ` Thomas Rast
2010-08-06 5:28 ` Bo Yang
2010-08-06 9:04 ` Thomas Rast
2010-08-05 16:11 ` [PATCH v4 12/18] Make rewrite_parents public to other part of git Bo Yang
2010-08-05 16:11 ` [PATCH v4 13/18] Make graph_next_line external " Bo Yang
2010-08-05 16:11 ` [PATCH v4 14/18] Add parent rewriting to line history browser Bo Yang
2010-08-05 16:11 ` [PATCH v4 15/18] Add --graph prefix before line history output Bo Yang
2010-08-05 16:11 ` [PATCH v4 16/18] Add --full-line-diff option Bo Yang
2010-08-05 16:11 ` [PATCH v4 17/18] Add test cases for '--graph' of line level log Bo Yang
2010-08-05 16:11 ` [PATCH v4 18/18] Document line history browser Bo Yang
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201008052309.03193.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=struggleyb.nku@gmail.com \
/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.
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 NNTP newsgroup(s).