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

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

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Oct 20, 2023, 17:05 UTC
Message-ID
<CAPig+cTBYw9=Wo=TR8MD5xX9hgurnfR2Xzc_wHSYnL1R00=xpw@mail.gmail.com>
In-Reply-To
<5c8ef6bec1c99e0fae7ada903885a8e77f8137f9.1697819838.git.code@khaugsbakk.name>

On Fri, Oct 20, 2023 at 12:40 PM Kristoffer Haugsbakk <code@khaugsbakk.name> wrote:

Show 16 quoted lines
> Die gracefully when `git grep --no-index` is run outside of a Git
> repository and the path is outside the directory tree.
>
> If you are not in a Git repository and say:
>
>     git grep --no-index search ..
>
> You trigger a `BUG`:
>
>     BUG: environment.c:213: git environment hasn't been setup
>     Aborted (core dumped)
>
> Because `..` is a valid path which is treated as a pathspec. Then
> `pathspec` figures out that it is not in the current directory tree. The
> `BUG` is triggered when `pathspec` tries to advice the user about how the
> path is not in the current (non-existing) repository.
s/advice/advise/
(probably not worth a reroll)
> Reported-by: ks1322 ks1322 <ks1322@gmail.com>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Previous: Kristoffer HaugsbakkNext: Junio C Hamano
Message 13 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.