From: Junio C Hamano <gitster@pobox•com>
To: Jeff King <peff@peff•net>
Cc: Jonathan Tan <jonathantanmy@google•com>, git@vger•kernel.org
Subject: Re: [PATCH 5/7] grep: fix "--" rev/pathspec disambiguation
Date: Tue, 14 Feb 2017 11:18:36 -0800 [thread overview]
Message-ID: <xmqqpoik8ttf.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170214060555.yzh6hhi2t7pkeqvi@sigill.intra.peff.net> (Jeff King's message of "Tue, 14 Feb 2017 01:05:55 -0500")
Jeff King <peff@peff•net> writes:
> If we see "git grep pattern rev -- file" then we apply the
> usual rev/pathspec disambiguation rules: any "rev" before
> the "--" must be a revision, and we do not need to apply the
> verify_non_filename() check.
>
> But there are two bugs here:
>
> 1. We keep a seen_dashdash flag to handle this case, but
> we set it in the same left-to-right pass over the
> arguments in which we parse "rev".
>
> So when we see "rev", we do not yet know that there is
> a "--", and we mistakenly complain if there is a
> matching file.
>
> We can fix this by making a preliminary pass over the
> arguments to find the "--", and only then checking the rev
> arguments.
>
> 2. If we can't resolve "rev" but there isn't a dashdash,
> that's OK. We treat it like a path, and complain later
> if it doesn't exist.
>
> But if there _is_ a dashdash, then we know it must be a
> rev, and should treat it as such, complaining if it
> does not resolve. The current code instead ignores it
> and tries to treat it like a path.
>
> This patch fixes both bugs, and tries to comment the parsing
> flow a bit better.
Good. Thanks.
next prev parent reply other threads:[~2017-02-14 19:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 0:11 [PATCH for NEXT] grep: do not unnecessarily query repo for "--" Jonathan Tan
2017-02-14 1:20 ` Jeff King
2017-02-14 6:00 ` [PATCH 0/7] grep rev/path parsing fixes Jeff King
2017-02-14 6:02 ` [PATCH 1/7] grep: move thread initialization a little lower Jeff King
2017-02-14 18:46 ` Brandon Williams
2017-02-14 6:03 ` [PATCH 2/7] grep: do not unnecessarily query repo for "--" Jeff King
2017-02-14 6:03 ` [PATCH 3/7] t7810: make "--no-index --" test more robust Jeff King
2017-02-14 6:04 ` [PATCH 4/7] grep: re-order rev-parsing loop Jeff King
2017-02-14 18:48 ` Brandon Williams
2017-02-14 6:05 ` [PATCH 5/7] grep: fix "--" rev/pathspec disambiguation Jeff King
2017-02-14 18:56 ` Brandon Williams
2017-02-14 19:51 ` Jeff King
2017-02-14 19:18 ` Junio C Hamano [this message]
2017-02-14 6:07 ` [PATCH 6/7] grep: avoid resolving revision names in --no-index case Jeff King
2017-02-14 16:53 ` Jonathan Tan
2017-02-14 18:04 ` Jeff King
2017-02-14 18:19 ` Jonathan Tan
2017-02-14 21:54 ` [PATCH 8/7] grep: treat revs the same for --untracked as for --no-index Jeff King
2017-02-14 21:58 ` Junio C Hamano
2017-02-14 6:08 ` [PATCH 7/7] grep: do not diagnose misspelt revs with --no-index Jeff King
2017-02-14 6:10 ` [PATCH 0/7] grep rev/path parsing fixes Jeff King
2017-02-14 16:58 ` Jonathan Tan
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=xmqqpoik8ttf.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=jonathantanmy@google$(echo .)com \
--cc=peff@peff$(echo .)net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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