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

Re: [PATCH] grep: die gracefully when outside repository

From
Kristoffer Haugsbakk <code@khaugsbakk.name>
Date
Oct 15, 2023, 08:00 UTC
Message-ID
<b953efce-da38-4dbc-9032-985481f3d721@app.fastmail.com>
In-Reply-To
<20231015032636.GC554702@coredump.intra.peff.net>
On Sun, Oct 15, 2023, at 05:26, Jeff King wrote:
Show 6 quoted lines
> Is it even reasonable for "grep --no-index" to care about leaving the
> tree in the first place? That is, is there a reason we should not allow:
>
>   git grep --no-index foo ../bar
>
> ?

On second thought yeah, it doesn't make sense. We are outside of any repository already so what does it matter where the file is relative to the current working directory?

It seems that `pathspec.c:init_pathspec_item` should let you through in this case.

-- 
Kristoffer Haugsbakk
Previous: Jeff KingNext: Junio C Hamano
Message 6 of 15 in “Bug: git grep --no-index 123 /dev/stdin crashes with SIGABRT”
  1. ks1322 ks1322Oct 14, 2023
  2. Kristoffer HaugsbakkOct 14, 2023
  3. Kristoffer HaugsbakkOct 14, 2023
  4. grep: die gracefully when outside repositoryKristoffer Haugsbakk, Oct 14, 2023
  5. Jeff KingOct 15, 2023
  6. Kristoffer HaugsbakkOct 15, 2023
  7. Junio C HamanoOct 15, 2023
  8. Junio C HamanoOct 17, 2023
  9. Kristoffer HaugsbakkOct 17, 2023
  10. Junio C HamanoOct 17, 2023
  11. Junio C HamanoOct 17, 2023
  12. grep: die gracefully when outside repositoryKristoffer Haugsbakk, Oct 20, 2023
  13. Eric SunshineOct 20, 2023
  14. Junio C HamanoOct 20, 2023
  15. grep: die gracefully when outside repositoryKristoffer Haugsbakk, Oct 20, 2023

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.