git-grep's "-z" option misbehaves in subdirectory
- From
Greg Hurrell <greg@hurrell.net>
- Date
- Apr 13, 2020, 21:55 UTC
- Message-ID
- <CAOyLvt9=wRfpvGGJqLMi7=wLWu881pOur8c9qNEg+Xqhf8W2ww@mail.gmail.com>
Hi,
It seems that `git-grep -lz` behaves differently depending on whether it is inside a subdirectory:
$ mkdir demo $ cd demo $ git init $ echo content > 'an "example".txt' $ mkdir nested $ echo content > 'nested/other "example".txt' $ git add . $ git commit -m Initial $ git grep -lz content an "example".txt^@nested/other "example".txt^@
Note that, as expected, the files are NUL-terminated and not wrapped in quotes. ("^@" represents NUL byte.)
$ cd nested $ git grep -lz content "other \"example\".txt"^@
As soon as we move into a subdirectory, files are wrapped in quotes and contain escapes, despite the "-z" switch. git-ls-files doesn't exhibit this behavior:
$ git ls-files -z other "example".txt
And git-grep doesn't either, if you pass "--full-name":
$ git grep -lz --full-name content nested/other "example".txt^@
Seeing this on Git v2.25.0 on macOS (10.13.6).
Does this seem like a bug, or expected behavior?
Cheers, Greg