git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] grep: --untracked and --exclude tests

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 27, 2011, 22:22 UTC
Message-ID
<7voby5wrpy.fsf_-_@alter.siamese.dyndns.org>
In-Reply-To
<7vty7xwrsf.fsf_-_@alter.siamese.dyndns.org>
Test various combinations of these options and --no-index.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 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 918d33f..2cbbdcc 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 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 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
 	)
 '
-- 
1.7.7.rc3.4.g8d714
Previous: Junio C HamanoNext: Bert Wesarg
Message 6 of 8 in “grep: do not use --index in the short usage output”
  1. 1/2 grep: do not use --index in the short usage outputBert Wesarg, Sep 15, 2011
  2. 2/2 grep --no-index: don't use git standard exclusionsBert Wesarg, Sep 15, 2011
  3. Junio C HamanoSep 15, 2011
  4. Bert WesargSep 16, 2011
  5. Re* [PATCH 2/2] grep --no-index: don't use git standard exclusionsJunio C Hamano, Sep 27, 2011
  6. 2/2 grep: --untracked and --exclude testsJunio C Hamano, Sep 27, 2011
  7. Bert WesargSep 28, 2011
  8. Junio C HamanoSep 28, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.