git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
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 1/8] Refactor parse_loc
Date: Tue, 14 Dec 2010 14:57:43 -0800	[thread overview]
Message-ID: <7v8vzsrmhk.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <ff9def9ac3f207b9f9be9c59ec3a313c9b3d4d84.1292291624.git.trast@student.ethz.ch> (Thomas Rast's message of "Tue\, 14 Dec 2010 03\:03\:24 +0100")

Thomas Rast <trast@student.ethz.ch> writes:

> diff --git a/line.c b/line.c
> new file mode 100644
> index 0000000..29898ec
> --- /dev/null
> +++ b/line.c
> @@ -0,0 +1,106 @@
> +#include "git-compat-util.h"
> +#include "line.h"
> +
> +/*
> + * Parse one item in the -L option
> + */
> +const char *parse_loc(const char *spec, nth_line_fn_t nth_line,
> +		void *data, long lines, long begin, long *ret)
> +{
> +        char *term;
> +        const char *line;
> +        long num;
> +        int reg_error;
> +        regex_t regexp;
> +        regmatch_t match[1];
> +
> +        /* Catch the '$' matcher, now it is used to match the last
> +         * line of the file. */

"now"?  What now, as opposed to which then?

Ahh, is it an artifact of squashing multiple patches, one that moves the
function and then another that adds a new feature?

In any case, please fix the style of multi-line comment.  I wouldn't mind
if you fixed the other one you moved from blame.c to this function (I
omitted it from the context but you know which one I mean).

> ...
> +int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,
> +		void *cb_data, long lines, long *begin, long *end)
> +{
> +	arg = parse_loc(arg, nth_line_cb, cb_data, lines, -1, begin);
> +
> +        if (*arg == ',') {
> +		arg = parse_loc(arg+1, nth_line_cb, cb_data, lines, *begin+1, end);
> +		if (*begin > *end) {
> +			long tmp = *begin;
> +			*begin = *end;
> +			*end = tmp;
> +		}

It is somewhat unfortunate that this "swap begin and end given -L9,4" is
done here not in the caller---for some callers 9,4 and 4,9 may mean
different things.  But for now this would do.

> diff --git a/t/t8003-blame.sh b/t/t8003-blame.sh
> index 230143c..51d313e 100755
> --- a/t/t8003-blame.sh
> +++ b/t/t8003-blame.sh
> @@ -175,6 +175,12 @@ test_expect_success 'blame -L with invalid end' '
>  	grep "has only 2 lines" errors
>  '
>  
> +test_expect_success 'blame -L parses end' '
> +	git blame -L1,1 tres >out &&
> +	cat out &&
> +	test $(wc -l < out) -eq 1
> +'

What does this test exactly?  "end"?

  reply	other threads:[~2010-12-14 22:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-14  2:03 [PATCH v6 0/8] git log -L, cleaned up and (hopefully) fixed Thomas Rast
2010-12-14  2:03 ` [PATCH 1/8] Refactor parse_loc Thomas Rast
2010-12-14 22:57   ` Junio C Hamano [this message]
2010-12-14 23:06     ` Thomas Rast
2010-12-14 23:20       ` Junio C Hamano
2010-12-14  2:03 ` [PATCH 2/8] Export three functions from diff.c Thomas Rast
2010-12-14 23:08   ` Junio C Hamano
2010-12-14  2:03 ` [PATCH 3/8] Export rewrite_parents() for 'log -L' Thomas Rast
2010-12-14  2:03 ` [PATCH 4/8] Implement line-history search (git log -L) Thomas Rast
2010-12-14  2:03 ` [PATCH 5/8] log -L: support parent rewriting Thomas Rast
2010-12-14  2:03 ` [PATCH 6/8] log -L: add --graph prefix before output Thomas Rast
2010-12-14  2:03 ` [PATCH 7/8] log -L: add --full-line-diff option Thomas Rast
2010-12-14  2:03 ` [PATCH 8/8] log -L: implement move/copy detection (-M/-C) Thomas Rast

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=7v8vzsrmhk.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).