Thread (9 messages) 9 messages, 4 authors, 2023-10-20

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

From: Eric Sunshine <hidden>
Date: 2023-10-20 17:05:16

On Fri, Oct 20, 2023 at 12:40 PM Kristoffer Haugsbakk
[off-list ref] wrote:
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 <redacted>
Helped-by: Junio C Hamano [off-list ref]
Signed-off-by: Kristoffer Haugsbakk <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help