]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/grep.c
builtin/grep: add grep.fallbackToNoIndex config
[thirdparty/git.git] / builtin / grep.c
index d04f4400d9db8ef9f0b0dde0c8be46a11bd0e2f7..f8ed4f4182a87134513888719c30a0d32efee135 100644 (file)
@@ -770,9 +770,15 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                             PARSE_OPT_NO_INTERNAL_HELP);
        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