diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-08-10 22:15:12 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-08-10 22:15:12 -0700 |
commit | 67f272c2f21a3d5a372b113b91836455d45257a7 (patch) | |
tree | 3375c609596cb9086aef870b92fe71c86e235134 /t | |
parent | 08ac69685a5b6bea45df1fd62ea1d9b7c0258d0b (diff) | |
parent | a91f453f641ca9966a438bdd3896656b00423407 (diff) | |
download | git-67f272c2f21a3d5a372b113b91836455d45257a7.tar.gz |
Merge branch 'mk/grep-max-depth'
* mk/grep-max-depth:
grep: Add --max-depth option.
Diffstat (limited to 't')
-rwxr-xr-x | t/t7002-grep.sh | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index b13aa7e89a..b4709e28b5 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -25,13 +25,17 @@ test_expect_success setup ' echo foo mmap bar_mmap echo foo_mmap bar mmap baz } >file && + echo vvv >v && echo ww w >w && echo x x xx x >x && echo y yy >y && echo zzz > z && mkdir t && echo test >t/t && - git add file w x y z t/t hello.c && + echo vvv >t/v && + mkdir t/a && + echo vvv >t/a/v && + git add . && test_tick && git commit -m initial ' @@ -132,6 +136,51 @@ do ! git grep -c test $H | grep /dev/null ' + test_expect_success "grep --max-depth -1 $L" ' + { + echo ${HC}t/a/v:1:vvv + echo ${HC}t/v:1:vvv + echo ${HC}v:1:vvv + } >expected && + git grep --max-depth -1 -n -e vvv $H >actual && + test_cmp expected actual + ' + + test_expect_success "grep --max-depth 0 $L" ' + { + echo ${HC}v:1:vvv + } >expected && + git grep --max-depth 0 -n -e vvv $H >actual && + test_cmp expected actual + ' + + test_expect_success "grep --max-depth 0 -- '*' $L" ' + { + echo ${HC}t/a/v:1:vvv + echo ${HC}t/v:1:vvv + echo ${HC}v:1:vvv + } >expected && + git grep --max-depth 0 -n -e vvv $H -- "*" >actual && + test_cmp expected actual + ' + + test_expect_success "grep --max-depth 1 $L" ' + { + echo ${HC}t/v:1:vvv + echo ${HC}v:1:vvv + } >expected && + git grep --max-depth 1 -n -e vvv $H >actual && + test_cmp expected actual + ' + + test_expect_success "grep --max-depth 0 -- t $L" ' + { + echo ${HC}t/v:1:vvv + } >expected && + git grep --max-depth 0 -n -e vvv $H -- t >actual && + test_cmp expected actual + ' + done cat >expected <<EOF |