]> git.ipfire.org Git - thirdparty/git.git/commit - t/t7810-grep.sh
grep: follow conventions for printing paths w/ unusual chars
authorMatheus Tavares <matheus.bernardino@usp.br>
Sun, 19 Apr 2020 06:33:24 +0000 (03:33 -0300)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Apr 2020 20:01:43 +0000 (13:01 -0700)
commit45115d84901876b9300c1b6eba333cd8b25b1991
treef3946aadeaed5724cedd550e7b82442d052bed1e
parentde49261b050d9cd8ec73842356077bc5b606640f
grep: follow conventions for printing paths w/ unusual chars

grep does not follow the conventions used by other Git commands when
printing paths that contain unusual characters (as double-quotes or
newlines). Commands such as ls-files, commit, status and diff will:

- Quote and escape unusual pathnames, by default.
- Print names verbatim and unquoted when "-z" is used.

But grep *never* quotes/escapes absolute paths with unusual chars and
*always* quotes/escapes relative ones, even with "-z". Besides being
inconsistent in its own output, the deviation from other Git commands
can be confusing. So let's make it follow the two rules above and add
some tests for this new behavior. Note that, making grep quote/escape
all unusual paths by default, also make it fully compliant with the
core.quotePath configuration, which is currently ignored for absolute
paths.

Reported-by: Greg Hurrell <greg@hurrell.net>
Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-grep.txt
builtin/grep.c
t/t7810-grep.sh