Revert 30816237 and 7e62265
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@pobox.com>
Junio C Hamano committed
Feb 5, 2010 at 09:20 UTC
3c8f6c8c4f00414e66076c2c97c834d01f828491
4 files changed
+1
-96
Documentation/RelNotes-1.7.0.txt
-3
@@ -133,9 +133,6 @@ Updates since v1.6.6
133
* "git grep" does not rely on external grep anymore. It can use more than
134
one threads to accelerate the operation.
135
136
- * "git grep" learned "--no-index" option, to search inside contents that
137
- are not managed by git.
138
-
136
* "git grep" learned "--quiet" option.
137
138
* "git log" and friends learned "--glob=heads/*" syntax that is a more
builtin-grep.c
-40
@@ -14,7 +14,6 @@
14
#include "userdiff.h"
15
#include "grep.h"
16
#include "quote.h"
17
-#include "dir.h"
17
18
#ifndef NO_PTHREADS
19
#include "thread-utils.h"
@@ -646,24 +645,6 @@ static int grep_object(struct grep_opt *opt, const char **paths,
645
die("unable to grep from object of type %s", typename(obj->type));
646
}
647
649
-static int grep_directory(struct grep_opt *opt, const char **paths)
650
-{
651
- struct dir_struct dir;
652
- int i, hit = 0;
653
-
654
- memset(&dir, 0, sizeof(dir));
655
- setup_standard_excludes(&dir);
656
-
657
- fill_directory(&dir, paths);
658
- for (i = 0; i < dir.nr; i++) {
659
- hit |= grep_file(opt, dir.entries[i]->name);
660
- if (hit && opt->status_only)
661
- break;
662
- }
663
- free_grep_patterns(opt);
664
- return hit;
665
-}
666
-
648
static int context_callback(const struct option *opt, const char *arg,
649
int unset)
650
{
@@ -758,12 +739,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
739
const char **paths = NULL;
740
int i;
741
int dummy;
761
- int nongit = 0, use_index = 1;
742
struct option options[] = {
743
OPT_BOOLEAN(0, "cached", &cached,
744
"search in index instead of in the work tree"),
765
- OPT_BOOLEAN(0, "index", &use_index,
766
- "--no-index finds in contents not managed by git"),
745
OPT_GROUP(""),
746
OPT_BOOLEAN('v', "invert-match", &opt.invert,
747
"show non-matching lines"),
@@ -846,8 +824,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
824
OPT_END()
825
};
826
849
- prefix = setup_git_directory_gently(&nongit);
850
-
827
/*
828
* 'git grep -h', unlike 'git grep -h <pattern>', is a request
829
* to show usage information and exit.
@@ -885,10 +861,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
861
PARSE_OPT_STOP_AT_NON_OPTION |
862
PARSE_OPT_NO_INTERNAL_HELP);
863
888
- if (use_index && nongit)
889
- /* die the same way as if we did it at the beginning */
890
- setup_git_directory();
891
-
864
/* First unrecognized non-option token */
865
if (argc > 0 && !opt.pattern_list) {
866
append_grep_pattern(&opt, argv[0], "command line", 0,
@@ -950,18 +922,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
922
paths[1] = NULL;
923
}
924
953
- if (!use_index) {
954
- int hit;
955
- if (cached)
956
- die("--cached cannot be used with --no-index.");
957
- if (list.nr)
958
- die("--no-index cannot be used with revs.");
959
- hit = grep_directory(&opt, paths);
960
- if (use_threads)
961
- hit |= wait_all();
962
- return !hit;
963
- }
964
-
925
if (!list.nr) {
926
int hit;
927
if (!cached)
git.c
+1
-1
@@ -317,7 +317,7 @@ static void handle_internal_command(int argc, const char **argv)
317
{ "fsck-objects", cmd_fsck, RUN_SETUP },
318
{ "gc", cmd_gc, RUN_SETUP },
319
{ "get-tar-commit-id", cmd_get_tar_commit_id },
320
- { "grep", cmd_grep, USE_PAGER },
320
+ { "grep", cmd_grep, RUN_SETUP | USE_PAGER },
321
{ "hash-object", cmd_hash_object },
322
{ "help", cmd_help },
323
{ "index-pack", cmd_index_pack },
t/t7002-grep.sh
-52
@@ -434,56 +434,4 @@ test_expect_success 'grep -Fi' '
434
test_cmp expected actual
435
'
436
437
-test_expect_success 'outside of git repository' '
438
- rm -fr non &&
439
- mkdir -p non/git/sub &&
440
- echo hello >non/git/file1 &&
441
- echo world >non/git/sub/file2 &&
442
- echo ".*o*" >non/git/.gitignore &&
443
- {
444
- echo file1:hello &&
445
- echo sub/file2:world
446
- } >non/expect.full &&
447
- echo file2:world >non/expect.sub
448
- (
449
- GIT_CEILING_DIRECTORIES="$(pwd)/non/git" &&
450
- export GIT_CEILING_DIRECTORIES &&
451
- cd non/git &&
452
- test_must_fail git grep o &&
453
- git grep --no-index o >../actual.full &&
454
- test_cmp ../expect.full ../actual.full
455
- cd sub &&
456
- test_must_fail git grep o &&
457
- git grep --no-index o >../../actual.sub &&
458
- test_cmp ../../expect.sub ../../actual.sub
459
- )
460
-'
461
-
462
-test_expect_success 'inside git repository but with --no-index' '
463
- rm -fr is &&
464
- mkdir -p is/git/sub &&
465
- echo hello >is/git/file1 &&
466
- echo world >is/git/sub/file2 &&
467
- echo ".*o*" >is/git/.gitignore &&
468
- {
469
- echo file1:hello &&
470
- echo sub/file2:world
471
- } >is/expect.full &&
472
- : >is/expect.empty &&
473
- echo file2:world >is/expect.sub
474
- (
475
- cd is/git &&
476
- git init &&
477
- test_must_fail git grep o >../actual.full &&
478
- test_cmp ../expect.empty ../actual.full &&
479
- git grep --no-index o >../actual.full &&
480
- test_cmp ../expect.full ../actual.full &&
481
- cd sub &&
482
- test_must_fail git grep o >../../actual.sub &&
483
- test_cmp ../../expect.empty ../../actual.sub &&
484
- git grep --no-index o >../../actual.sub &&
485
- test_cmp ../../expect.sub ../../actual.sub
486
- )
487
-'
488
-
437
test_done