git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/7] grep rev/path parsing fixes

From
Jeff King <peff@peff.net>
Date
Feb 14, 2017, 06:00 UTC
Message-ID
<20170214060021.einv7372exbxa23z@sigill.intra.peff.net>
In-Reply-To
<20170214012037.u2eg2n7mvteullcx@sigill.intra.peff.net>
On Mon, Feb 13, 2017 at 08:20:37PM -0500, Jeff King wrote:
Show 11 quoted lines
> > If there is a repo and "foo" is a rev, the "--no-index or --untracked
> > cannot be used with revs." error would occur. If there is a repo and
> > "foo" is not a rev, this command would proceed as usual. If there is no
> > repo, the "setup_git_env called without repository" error would occur.
> > (This is my understanding from reading the code - I haven't tested it
> > out.)
> 
> Yes, it's easy to see that "git grep --no-index foo bar" outside of a
> repo generates the same BUG. I suspect that "--no-index" should just
> disable looking up revs entirely, even if we are actually in a
> repository directory.

I've fixed that, along with a few other bugs and cleanups. The complete series is below. Patch 2 is your (untouched) patch. My suggestions for your test are in patch 3, which can either remain on its own or be squashed in.

  [1/7]: grep: move thread initialization a little lower
  [2/7]: grep: do not unnecessarily query repo for "--"
  [3/7]: t7810: make "--no-index --" test more robust
  [4/7]: grep: re-order rev-parsing loop
  [5/7]: grep: fix "--" rev/pathspec disambiguation
  [6/7]: grep: avoid resolving revision names in --no-index case
  [7/7]: grep: do not diagnose misspelt revs with --no-index
 builtin/grep.c  | 78 +++++++++++++++++++++++++++++++++++++++------------------
 t/t7810-grep.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 119 insertions(+), 25 deletions(-)
-Peff
Previous: Jeff KingNext: Jeff King
Message 3 of 22 in “grep: do not unnecessarily query repo for "--"”
  1. grep: do not unnecessarily query repo for "--"Jonathan Tan, Feb 14, 2017
  2. Jeff KingFeb 14, 2017
  3. 0/7 grep rev/path parsing fixesJeff King, Feb 14, 2017
  4. 1/7 grep: move thread initialization a little lowerJeff King, Feb 14, 2017
  5. Brandon WilliamsFeb 14, 2017
  6. 2/7 grep: do not unnecessarily query repo for "--"Jeff King, Feb 14, 2017
  7. 3/7 t7810: make "--no-index --" test more robustJeff King, Feb 14, 2017
  8. 4/7 grep: re-order rev-parsing loopJeff King, Feb 14, 2017
  9. Brandon WilliamsFeb 14, 2017
  10. 5/7 grep: fix "--" rev/pathspec disambiguationJeff King, Feb 14, 2017
  11. Brandon WilliamsFeb 14, 2017
  12. Jeff KingFeb 14, 2017
  13. Junio C HamanoFeb 14, 2017
  14. 6/7 grep: avoid resolving revision names in --no-index caseJeff King, Feb 14, 2017
  15. Jonathan TanFeb 14, 2017
  16. Jeff KingFeb 14, 2017
  17. Jonathan TanFeb 14, 2017
  18. 8/7 grep: treat revs the same for --untracked as for --no-indexJeff King, Feb 14, 2017
  19. Junio C HamanoFeb 14, 2017
  20. 7/7 grep: do not diagnose misspelt revs with --no-indexJeff King, Feb 14, 2017
  21. Jeff KingFeb 14, 2017
  22. Jonathan TanFeb 14, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.