git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git-grep's "-z" option misbehaves in subdirectory
@ 2020-04-13 21:55 Greg Hurrell
  2020-04-13 23:33 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Greg Hurrell @ 2020-04-13 21:55 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-04-19  6:33 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 21:55 git-grep's "-z" option misbehaves in subdirectory Greg Hurrell
2020-04-13 23:33 ` Junio C Hamano
2020-04-14  7:42 ` Matheus Tavares
2020-04-16 18:59 ` git-grep's "-z" option misbehaves in subdirectory Matheus Tavares Bernardino
2020-04-16 20:07   ` Junio C Hamano
2020-04-17  6:04     ` [PATCH] grep: follow conventions for printing paths w/ unusual chars Matheus Tavares
2020-04-17  6:45       ` Junio C Hamano
2020-04-17 21:19         ` Matheus Tavares Bernardino
2020-04-17 21:35           ` Junio C Hamano
2020-04-18 13:13       ` Johannes Schindelin
2020-04-18 14:56         ` Johannes Schindelin
2020-04-19  6:27           ` Matheus Tavares Bernardino
2020-04-19  6:33       ` [PATCH v2] " Matheus Tavares

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).