From: Jeff King <peff@peff.net>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 1/3] grep: prepare for new header field filter
Date: Sat, 29 Sep 2012 01:22:02 -0400 [thread overview]
Message-ID: <20120929052202.GA3330@sigill.intra.peff.net> (raw)
In-Reply-To: <1348893689-20240-2-git-send-email-pclouds@gmail.com>
On Sat, Sep 29, 2012 at 11:41:27AM +0700, Nguyen Thai Ngoc Duy wrote:
> diff --git a/grep.c b/grep.c
> index 898be6e..8d73995 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -720,7 +720,14 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
> if (strncmp(bol, field, len))
> return 0;
> bol += len;
> - saved_ch = strip_timestamp(bol, &eol);
> + switch (p->field) {
> + case GREP_HEADER_AUTHOR:
> + case GREP_HEADER_COMMITTER:
> + saved_ch = strip_timestamp(bol, &eol);
> + break;
> + default:
> + break;
> + }
Reading this hunk, I wondered what happens to saved_ch if we do not set
it here. Fortunately it is initialized to 0, as we already have to
handle the non-header case. Then later we do this, which does introduce
a new condition (saved_ch was not set, but we trigger the first half of
the conditional):
if (p->token == GREP_PATTERN_HEAD && saved_ch)
*eol = saved_ch;
However, the second half of that conditional (which previously was only
triggered when we tried to split the timestamp, but there was a bogus
line with no ">" on it) prevents us from overwriting *eol.
So I think it is good, but it was non-obvious enough that I wanted to
save other reviewers from investigating it. The rest of the patch looks
good to me, as well.
-Peff
next prev parent reply other threads:[~2012-09-29 5:22 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-26 12:12 [PATCH] revision: add --reflog-message=<pattern> to grep reflog messages Nguyễn Thái Ngọc Duy
2012-09-26 14:07 ` Junio C Hamano
2012-09-26 14:15 ` Nguyen Thai Ngoc Duy
2012-09-26 19:28 ` Junio C Hamano
2012-09-27 11:36 ` [PATCH] revision: add --reflog-message " Nguyễn Thái Ngọc Duy
2012-09-27 17:09 ` Junio C Hamano
2012-09-27 17:28 ` Jeff King
2012-09-27 18:16 ` Junio C Hamano
2012-09-28 7:01 ` [PATCH 1/3] grep: generalize header grep code to accept arbitrary headers Nguyễn Thái Ngọc Duy
2012-09-28 7:01 ` [PATCH 2/3] revision: add --grep-reflog to filter commits by reflog messages Nguyễn Thái Ngọc Duy
2012-09-28 17:55 ` Junio C Hamano
2012-09-29 4:41 ` Nguyễn Thái Ngọc Duy
2012-09-29 4:41 ` [PATCH 1/3] grep: prepare for new header field filter Nguyễn Thái Ngọc Duy
2012-09-29 5:22 ` Jeff King [this message]
2012-09-29 4:41 ` [PATCH 2/3] revision: add --grep-reflog to filter commits by reflog messages Nguyễn Thái Ngọc Duy
2012-09-29 5:30 ` Jeff King
2012-09-29 5:54 ` Junio C Hamano
2012-09-29 6:13 ` Nguyen Thai Ngoc Duy
2012-09-29 19:11 ` Junio C Hamano
2012-09-30 3:45 ` Nguyen Thai Ngoc Duy
2012-09-29 6:16 ` Jeff King
2012-09-29 4:41 ` [PATCH 3/3] revision: make --grep search in notes too if shown Nguyễn Thái Ngọc Duy
2012-09-29 5:35 ` [PATCH 2/3] revision: add --grep-reflog to filter commits by reflog messages Junio C Hamano
2012-09-28 7:01 ` [PATCH 3/3] revision: make --grep search in notes too if shown Nguyễn Thái Ngọc Duy
2012-09-28 17:55 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120929052202.GA3330@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@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).