diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-09-27 13:43:12 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-10-04 18:33:45 -0700 |
commit | 0a93fb8a9cc6fa1bf7dba6b498cba3f57f5017a1 (patch) | |
tree | 50daede8ecb40d0cff0c0968cd9d3337b8d520b3 /t | |
parent | grep --no-index: don't use git standard exclusions (diff) | |
download | tgif-0a93fb8a9cc6fa1bf7dba6b498cba3f57f5017a1.tar.xz |
grep: teach --untracked and --exclude-standard options
In a working tree of a git managed repository, "grep --untracked" would
find the specified patterns from files in untracked files in addition to
its usual behaviour of finding them in the tracked files.
By default, when working with "--no-index" option, "grep" does not pay
attention to .gitignore mechanism. "grep --no-index --exclude-standard"
can be used to tell the command to use .gitignore and stop reporting hits
from files that would be ignored. Also, when working without "--no-index",
"grep" honors .gitignore mechanism, and "grep --no-exclude-standard" can
be used to tell the command to include hits from files that are ignored.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t7002-grep.sh | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index 918d33f7d1..bf7877d930 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -455,6 +455,23 @@ test_expect_success 'outside of git repository' ' test_must_fail git grep o && git grep --no-index o >../../actual.sub && test_cmp ../../expect.sub ../../actual.sub + ) && + + echo ".*o*" >non/git/.gitignore && + ( + GIT_CEILING_DIRECTORIES="$(pwd)/non/git" && + export GIT_CEILING_DIRECTORIES && + cd non/git && + test_must_fail git grep o && + git grep --no-index --exclude-standard o >../actual.full && + test_cmp ../expect.full ../actual.full && + + { + echo ".gitignore:.*o*" + cat ../expect.full + } >../expect.with.ignored && + git grep --no-index --no-exclude o >../actual.full && + test_cmp ../expect.with.ignored ../actual.full ) ' @@ -465,9 +482,12 @@ test_expect_success 'inside git repository but with --no-index' ' echo world >is/git/sub/file2 && echo ".*o*" >is/git/.gitignore && { - echo ".gitignore:.*o*" && echo file1:hello && echo sub/file2:world + } >is/expect.unignored && + { + echo ".gitignore:.*o*" && + cat is/expect.unignored } >is/expect.full && : >is/expect.empty && echo file2:world >is/expect.sub @@ -476,12 +496,24 @@ test_expect_success 'inside git repository but with --no-index' ' git init && test_must_fail git grep o >../actual.full && test_cmp ../expect.empty ../actual.full && + + git grep --untracked o >../actual.unignored && + test_cmp ../expect.unignored ../actual.unignored && + git grep --no-index o >../actual.full && test_cmp ../expect.full ../actual.full && + + git grep --no-index --exclude-standard o >../actual.unignored && + test_cmp ../expect.unignored ../actual.unignored && + 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 && + + git grep --untracked o >../../actual.sub && test_cmp ../../expect.sub ../../actual.sub ) ' |