Merge branch 'lv/add-doc-working-tree'
[gitweb.git] / builtin / grep.c
index 06ab68223a13b35612e2cb283d778a9c904b5528..8c516a95438e5aa997049da24160764ff4ca985c 100644 (file)
@@ -573,7 +573,7 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
        patterns = from_stdin ? stdin : fopen(arg, "r");
        if (!patterns)
                die_errno(_("cannot open '%s'"), arg);
-       while (strbuf_getline(&sb, patterns, '\n') == 0) {
+       while (strbuf_getline(&sb, patterns) == 0) {
                /* ignore empty line like grep does */
                if (sb.len == 0)
                        continue;
@@ -768,9 +768,15 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                             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