diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-04-28 22:50:09 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-04-28 22:50:09 (GMT) |
commit | 33a106098824f50ec0e2e7d642cea26f9a384da4 (patch) | |
tree | 82cf90ba177f38481e628803fbc9cc8b3bbe669d /t | |
parent | d3fc8dc53a7ef9f33a5d9604b382e24408a9b7be (diff) | |
parent | 45115d84901876b9300c1b6eba333cd8b25b1991 (diff) | |
download | git-33a106098824f50ec0e2e7d642cea26f9a384da4.zip git-33a106098824f50ec0e2e7d642cea26f9a384da4.tar.gz git-33a106098824f50ec0e2e7d642cea26f9a384da4.tar.bz2 |
Merge branch 'mt/grep-cquote-path'
"git grep" did not quote a path with unusual character like other
commands (like "git diff", "git status") do, but did quote when run
from a subdirectory, both of which has been corrected.
* mt/grep-cquote-path:
grep: follow conventions for printing paths w/ unusual chars
Diffstat (limited to 't')
-rwxr-xr-x | t/t7810-grep.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 7d7b396..991d5bd 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -72,6 +72,11 @@ test_expect_success setup ' # Still a no-op. function dummy() {} EOF + if test_have_prereq FUNNYNAMES + then + echo unusual >"\"unusual\" pathname" && + echo unusual >"t/nested \"unusual\" pathname" + fi && git add . && test_tick && git commit -m initial @@ -481,6 +486,48 @@ do git grep --count -h -e b $H -- ab >actual && test_cmp expected actual ' + + test_expect_success FUNNYNAMES "grep $L should quote unusual pathnames" ' + cat >expected <<-EOF && + ${HC}"\"unusual\" pathname":unusual + ${HC}"t/nested \"unusual\" pathname":unusual + EOF + git grep unusual $H >actual && + test_cmp expected actual + ' + + test_expect_success FUNNYNAMES "grep $L in subdir should quote unusual relative pathnames" ' + cat >expected <<-EOF && + ${HC}"nested \"unusual\" pathname":unusual + EOF + ( + cd t && + git grep unusual $H + ) >actual && + test_cmp expected actual + ' + + test_expect_success FUNNYNAMES "grep -z $L with unusual pathnames" ' + cat >expected <<-EOF && + ${HC}"unusual" pathname:unusual + ${HC}t/nested "unusual" pathname:unusual + EOF + git grep -z unusual $H >actual && + tr "\0" ":" <actual >actual-replace-null && + test_cmp expected actual-replace-null + ' + + test_expect_success FUNNYNAMES "grep -z $L in subdir with unusual relative pathnames" ' + cat >expected <<-EOF && + ${HC}nested "unusual" pathname:unusual + EOF + ( + cd t && + git grep -z unusual $H + ) >actual && + tr "\0" ":" <actual >actual-replace-null && + test_cmp expected actual-replace-null + ' done cat >expected <<EOF |