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

Re: Bug: git grep --no-index 123 /dev/stdin crashes with SIGABRT

From: Kristoffer Haugsbakk <hidden>
Date: 2023-10-14 18:14:38

Hi ks1322 

On Sat, Oct 14, 2023, at 17:42, ks1322 ks1322 wrote:
Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
`git grep --no-index 123 /dev/stdin` outside of git repository

What did you expect to happen? (Expected behavior)
Ability to grep input from stdin

What happened instead? (Actual behavior)
`git grep` crashed with SIGABRT

$ git grep --no-index 123 /dev/stdin
BUG: environment.c:215: git environment hasn't been setup
Aborted (core dumped)

What's different between what you expected and what actually happened?
Crash, no grep result
It looks like `setup.c:verify_filename` fails to deny paths that are not
transitive children (or whatever the term) of the directory that git(1) is
running in:

    $ git -C ~/IdeaProjects/ grep --no-index dfddf ~
    BUG: environment.c:213: git environment hasn't been setup
    Aborted (core dumped)

So `builtin/grep.c` goes past that check, into
`pathspec.c:init_pathspec_item` and dies at line 472 since that function
assumes that we are in a Git repository.

-- 
Kristoffer Haugsbakk
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help