From: Junio C Hamano Date: Wed, 20 Jan 2016 19:43:38 +0000 (-0800) Subject: Merge branch 'tg/grep-no-index-fallback' X-Git-Tag: v2.8.0-rc0~106 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=52bae62f7888edf5e87ef85bbe04803474f67c10;p=thirdparty%2Fgit.git Merge branch 'tg/grep-no-index-fallback' "git grep" by default does not fall back to its "--no-index" behaviour outside a directory under Git's control (otherwise the user may by mistake end up running a huge recursive search); with a new configuration (set in $HOME/.gitconfig--by definition this cannot be set in the config file per project), this safety can be disabled. * tg/grep-no-index-fallback: builtin/grep: add grep.fallbackToNoIndex config t7810: correct --no-index test --- 52bae62f7888edf5e87ef85bbe04803474f67c10 diff --cc Documentation/config.txt index beb18da143,d41b2a61a8..07f7a3b771 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@@ -1450,10 -1399,10 +1450,14 @@@ grep.extendedRegexp: option is ignored when the 'grep.patternType' option is set to a value other than 'default'. +grep.threads:: + Number of grep worker threads to use. + See `grep.threads` in linkgit:git-grep[1] for more information. + + grep.fallbackToNoIndex:: + If set to true, fall back to git grep --no-index if git grep + is executed outside of a git repository. Defaults to false. + gpg.program:: Use this custom program instead of "gpg" found on $PATH when making or verifying a PGP signature. The program must support the diff --cc builtin/grep.c index 06ab68223a,f8ed4f4182..5526fd7056 --- a/builtin/grep.c +++ b/builtin/grep.c @@@ -765,12 -766,19 +765,18 @@@ int cmd_grep(int argc, const char **arg */ argc = parse_options(argc, argv, prefix, options, grep_usage, PARSE_OPT_KEEP_DASHDASH | - PARSE_OPT_STOP_AT_NON_OPTION | - PARSE_OPT_NO_INTERNAL_HELP); + PARSE_OPT_STOP_AT_NON_OPTION); grep_commit_pattern_type(pattern_type_arg, &opt); - if (use_index && !startup_info->have_repository) - /* die the same way as if we did it at the beginning */ - setup_git_directory(); + if (use_index && !startup_info->have_repository) { + int fallback = 0; + git_config_get_bool("grep.fallbacktonoindex", &fallback); + if (fallback) + use_index = 0; + else + /* die the same way as if we did it at the beginning */ + setup_git_directory(); + } /* * skip a -- separator; we know it cannot be