X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Ft7002-grep.sh;h=e249c3ed4176b4934ae57541ab8b671801968eae;hb=c00cf45fa35d8aaa31c479ae7502286837fc4dc6;hp=af63d6ec6dfdf34b7a8ab4c19547d1d84cc184f2;hpb=4fd8145c0cb419a8b262115be8db9e18d63632db;p=git.git diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index af63d6ec6..e249c3ed4 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -442,6 +442,58 @@ test_expect_success 'grep -Fi' ' test_cmp expected actual ' +test_expect_success 'outside of git repository' ' + rm -fr non && + mkdir -p non/git/sub && + echo hello >non/git/file1 && + echo world >non/git/sub/file2 && + echo ".*o*" >non/git/.gitignore && + { + echo file1:hello && + echo sub/file2:world + } >non/expect.full && + echo file2:world >non/expect.sub + ( + GIT_CEILING_DIRECTORIES="$(pwd)/non/git" && + export GIT_CEILING_DIRECTORIES && + cd non/git && + test_must_fail git grep o && + git grep --no-index o >../actual.full && + test_cmp ../expect.full ../actual.full + cd sub && + test_must_fail git grep o && + git grep --no-index o >../../actual.sub && + test_cmp ../../expect.sub ../../actual.sub + ) +' + +test_expect_success 'inside git repository but with --no-index' ' + rm -fr is && + mkdir -p is/git/sub && + echo hello >is/git/file1 && + echo world >is/git/sub/file2 && + echo ".*o*" >is/git/.gitignore && + { + echo file1:hello && + echo sub/file2:world + } >is/expect.full && + : >is/expect.empty && + echo file2:world >is/expect.sub + ( + cd is/git && + git init && + test_must_fail git grep o >../actual.full && + test_cmp ../expect.empty ../actual.full && + git grep --no-index o >../actual.full && + test_cmp ../expect.full ../actual.full && + cd sub && + test_must_fail git grep o >../../actual.sub && + test_cmp ../../expect.empty ../../actual.sub && + git grep --no-index o >../../actual.sub && + test_cmp ../../expect.sub ../../actual.sub + ) +' + test_expect_success 'setup double-dash tests' ' cat >double-dash <