Junio C Hamano <gitster@xxxxxxxxx> writes: > 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. Sorry; spoke too fast. We'd also need to revert the one to git.c (7e62265 (grep: prepare to run outside of a work tree, 2010-01-15) as well. diff --git a/builtin-grep.c b/builtin-grep.c index bff1e68..26d4deb 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -739,7 +739,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix) const char **paths = NULL; int i; int dummy; - int nongit = 0, use_index = 1; struct option options[] = { OPT_BOOLEAN(0, "cached", &cached, "search in index instead of in the work tree"), @@ -825,8 +824,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix) OPT_END() }; - prefix = setup_git_directory_gently(&nongit); - /* * 'git grep -h', unlike 'git grep -h <pattern>', is a request * to show usage information and exit. @@ -864,10 +861,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix) PARSE_OPT_STOP_AT_NON_OPTION | PARSE_OPT_NO_INTERNAL_HELP); - if (use_index && nongit) - /* die the same way as if we did it at the beginning */ - setup_git_directory(); - /* First unrecognized non-option token */ if (argc > 0 && !opt.pattern_list) { append_grep_pattern(&opt, argv[0], "command line", 0, diff --git a/git.c b/git.c index b3e23f1..4c3028c 100644 --- a/git.c +++ b/git.c @@ -317,7 +317,7 @@ static void handle_internal_command(int argc, const char **argv) { "fsck-objects", cmd_fsck, RUN_SETUP }, { "gc", cmd_gc, RUN_SETUP }, { "get-tar-commit-id", cmd_get_tar_commit_id }, - { "grep", cmd_grep, USE_PAGER }, + { "grep", cmd_grep, RUN_SETUP | USE_PAGER }, { "hash-object", cmd_hash_object }, { "help", cmd_help }, { "index-pack", cmd_index_pack }, -- 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