diff options
Diffstat (limited to 't/t7810-grep.sh')
-rwxr-xr-x | t/t7810-grep.sh | 105 |
1 files changed, 72 insertions, 33 deletions
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 2e1bb61b41..5830733f3d 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -6,6 +6,9 @@ test_description='git grep various. ' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh cat >hello.c <<EOF @@ -72,6 +75,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 @@ -412,7 +420,7 @@ do test_cmp expected actual ' - test_expect_success !PCRE "grep $L with grep.patterntype=perl errors without PCRE" ' + test_expect_success !FAIL_PREREQS,!PCRE "grep $L with grep.patterntype=perl errors without PCRE" ' test_must_fail git -c grep.patterntype=perl grep "foo.*bar" ' @@ -481,6 +489,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 @@ -640,21 +690,9 @@ test_expect_success 'grep -C1 hunk mark between files' ' ' test_expect_success 'log grep setup' ' - echo a >>file && - test_tick && - GIT_AUTHOR_NAME="With * Asterisk" \ - GIT_AUTHOR_EMAIL="xyzzy@frotz.com" \ - git commit -a -m "second" && - - echo a >>file && - test_tick && - git commit -a -m "third" && - - echo a >>file && - test_tick && - GIT_AUTHOR_NAME="Night Fall" \ - GIT_AUTHOR_EMAIL="nitfol@frobozz.com" \ - git commit -a -m "fourth" + test_commit --append --author "With * Asterisk <xyzzy@frotz.com>" second file a && + test_commit --append third file a && + test_commit --append --author "Night Fall <nitfol@frobozz.com>" fourth file a ' test_expect_success 'log grep (1)' ' @@ -931,7 +969,8 @@ do " done -test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'grep --threads=N or pack.threads=N warns when no pthreads' ' +test_expect_success !PTHREADS,!FAIL_PREREQS \ + 'grep --threads=N or pack.threads=N warns when no pthreads' ' git grep --threads=2 Hello hello_world 2>err && grep ^warning: err >warnings && test_line_count = 1 warnings && @@ -1159,19 +1198,19 @@ test_expect_success 'grep -e -- -- path' ' ' test_expect_success 'dashdash disambiguates rev as rev' ' - test_when_finished "rm -f master" && - echo content >master && - echo master:hello.c >expect && - git grep -l o master -- hello.c >actual && + test_when_finished "rm -f main" && + echo content >main && + echo main:hello.c >expect && + git grep -l o main -- hello.c >actual && test_cmp expect actual ' test_expect_success 'dashdash disambiguates pathspec as pathspec' ' - test_when_finished "git rm -f master" && - echo content >master && - git add master && - echo master:content >expect && - git grep o -- master >actual && + test_when_finished "git rm -f main" && + echo content >main && + git add main && + echo main:content >expect && + git grep o -- main >actual && test_cmp expect actual ' @@ -1207,15 +1246,15 @@ test_expect_success 'grep --no-index pattern -- path' ' ' test_expect_success 'grep --no-index complains of revs' ' - test_must_fail git grep --no-index o master -- 2>err && + test_must_fail git grep --no-index o main -- 2>err && test_i18ngrep "cannot be used with revs" err ' test_expect_success 'grep --no-index prefers paths to revs' ' - test_when_finished "rm -f master" && - echo content >master && - echo master:content >expect && - git grep --no-index o master >actual && + test_when_finished "rm -f main" && + echo content >main && + echo main:content >expect && + git grep --no-index o main >actual && test_cmp expect actual ' @@ -1234,7 +1273,7 @@ test_expect_success PCRE 'grep --perl-regexp pattern' ' test_cmp expected actual ' -test_expect_success !PCRE 'grep --perl-regexp pattern errors without PCRE' ' +test_expect_success !FAIL_PREREQS,!PCRE 'grep --perl-regexp pattern errors without PCRE' ' test_must_fail git grep --perl-regexp "foo.*bar" ' @@ -1249,7 +1288,7 @@ test_expect_success LIBPCRE2 "grep -P with (*NO_JIT) doesn't error out" ' ' -test_expect_success !PCRE 'grep -P pattern errors without PCRE' ' +test_expect_success !FAIL_PREREQS,!PCRE 'grep -P pattern errors without PCRE' ' test_must_fail git grep -P "foo.*bar" ' |