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

[PATCH 2/2] grep --no-index: don't use git standard exclusions

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Sep 15, 2011, 18:26 UTC
Message-ID
<7b3551dd84a2bfec78c8db1d14dd2d0e6dda35f6.1316110876.git.bert.wesarg@googlemail.com>
In-Reply-To
<2f376e61802a1a38c67698d5ec263d1807b1fcee.1316110876.git.bert.wesarg@googlemail.com>

The --no-index mode is intended to be used outside of a git repository, but enabling the git standard exclusions outside a git repositories does not make any sense. Especially if it is not possible to disable them.

Thus do not use the standard exclusions in --no-index mode.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
On Wed, Jul 20, 2011 at 22:57, Junio C Hamano <gitster@pobox.com> wrote:
>  - Since 3081623 (grep --no-index: allow use of "git grep" outside a git
>   repository, 2010-01-15) and 59332d1 (Resurrect "git grep --no-index",
>   2010-02-06), "grep --no-index" incorrectly paid attention to the
>   exclude patterns. We shouldn't have, and we'd fix that bug.
Fix this bug.
 builtin/grep.c  |    1 -
 t/t7810-grep.sh |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/builtin/grep.c b/builtin/grep.c
index e0562b0..127584e 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -643,7 +643,6 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec)
 	int i, hit = 0;
 
 	memset(&dir, 0, sizeof(dir));
-	setup_standard_excludes(&dir);
 
 	fill_directory(&dir, pathspec->raw);
 	for (i = 0; i < dir.nr; i++) {
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index 0d60016..4a05e79 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -554,7 +554,6 @@ test_expect_success 'outside of git repository' '
 	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
@@ -581,6 +580,7 @@ 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.full &&
-- 
1.7.6.789.gb4599
Previous: Bert WesargNext: Junio C Hamano
Message 2 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.