Re: [PATCH] Remove .git auto detection from setup_git_env()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> writes:

> It has been a while since I looked at this code, but I think this is a
> good direction forward. I remember trying something like this and
> getting discouraged at all of the ensuing breakage. So if you can track
> down all of the fallouts and fix them, I think we will be better off in
> the long run.

I agree.

This topic started from "We broke 'git grep' in .git directory" and I
think it is the sanest to revert 3081623 (grep --no-index: allow use of
"git grep" outside a git repository, 2010-01-15) which nobody has used so
far in any released version of git, until we sort this out at least.

Every time we touch work-tree related codepath (like René's patch does) we
seem to inadvertently break something else.  It's too late for that kind
of fixes for this cycle and "grep  --no-index" should go.

-- >8 --
Subject: [PATCH] Revert 308162372d0aa202ff45743e02253e20a4fac4d7

It seems that we have bad interaction with the code related to
GIT_WORK_TREE and "grep --no-index", and broke running grep inside
the .git directory.  For now, just revert it and resurrect it after
1.7.0 ships.

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 Documentation/RelNotes-1.7.0.txt |    3 --
 builtin-grep.c                   |   33 ------------------------
 t/t7002-grep.sh                  |   52 --------------------------------------
 3 files changed, 0 insertions(+), 88 deletions(-)

diff --git a/Documentation/RelNotes-1.7.0.txt b/Documentation/RelNotes-1.7.0.txt
index 255666f..f632662 100644
--- a/Documentation/RelNotes-1.7.0.txt
+++ b/Documentation/RelNotes-1.7.0.txt
@@ -133,9 +133,6 @@ Updates since v1.6.6
  * "git grep" does not rely on external grep anymore.  It can use more than
    one threads to accelerate the operation.
 
- * "git grep" learned "--no-index" option, to search inside contents that
-   are not managed by git.
-
  * "git grep" learned "--quiet" option.
 
  * "git log" and friends learned "--glob=heads/*" syntax that is a more
diff --git a/builtin-grep.c b/builtin-grep.c
index 0ef849c..bff1e68 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -14,7 +14,6 @@
 #include "userdiff.h"
 #include "grep.h"
 #include "quote.h"
-#include "dir.h"
 
 #ifndef NO_PTHREADS
 #include "thread-utils.h"
@@ -646,24 +645,6 @@ static int grep_object(struct grep_opt *opt, const char **paths,
 	die("unable to grep from object of type %s", typename(obj->type));
 }
 
-static int grep_directory(struct grep_opt *opt, const char **paths)
-{
-	struct dir_struct dir;
-	int i, hit = 0;
-
-	memset(&dir, 0, sizeof(dir));
-	setup_standard_excludes(&dir);
-
-	fill_directory(&dir, paths);
-	for (i = 0; i < dir.nr; i++) {
-		hit |= grep_file(opt, dir.entries[i]->name);
-		if (hit && opt->status_only)
-			break;
-	}
-	free_grep_patterns(opt);
-	return hit;
-}
-
 static int context_callback(const struct option *opt, const char *arg,
 			    int unset)
 {
@@ -762,8 +743,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 	struct option options[] = {
 		OPT_BOOLEAN(0, "cached", &cached,
 			"search in index instead of in the work tree"),
-		OPT_BOOLEAN(0, "index", &use_index,
-			"--no-index finds in contents not managed by git"),
 		OPT_GROUP(""),
 		OPT_BOOLEAN('v', "invert-match", &opt.invert,
 			"show non-matching lines"),
@@ -950,18 +929,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 		paths[1] = NULL;
 	}
 
-	if (!use_index) {
-		int hit;
-		if (cached)
-			die("--cached cannot be used with --no-index.");
-		if (list.nr)
-			die("--no-index cannot be used with revs.");
-		hit = grep_directory(&opt, paths);
-		if (use_threads)
-			hit |= wait_all();
-		return !hit;
-	}
-
 	if (!list.nr) {
 		int hit;
 		if (!cached)
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index bf4d4dc..7144f81 100755
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
@@ -434,56 +434,4 @@ 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_done
-- 
1.7.0.rc1.204.gb96e5

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]