Merge branch 'maint'
[gitweb.git] / builtin / grep.c
index e741aca18cc1c9c3e5cfef3db996d05956bedc2d..643938d905fb134a1e65e3684e8e5feb06b01a59 100644 (file)
@@ -265,11 +265,8 @@ static int grep_config(const char *var, const char *value, void *cb)
        struct grep_opt *opt = cb;
        char *color = NULL;
 
-       switch (userdiff_config(var, value)) {
-       case 0: break;
-       case -1: return -1;
-       default: return 0;
-       }
+       if (userdiff_config(var, value) < 0)
+               return -1;
 
        if (!strcmp(var, "grep.extendedregexp")) {
                if (git_config_bool(var, value))
@@ -687,9 +684,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
        struct option options[] = {
                OPT_BOOLEAN(0, "cached", &cached,
                        "search in index instead of in the work tree"),
-               { OPTION_BOOLEAN, 0, "index", &use_index, NULL,
-                       "finds in contents not managed by git",
-                       PARSE_OPT_NOARG | PARSE_OPT_NEGHELP },
+               OPT_NEGBIT(0, "no-index", &use_index,
+                        "finds in contents not managed by git", 1),
                OPT_BOOLEAN(0, "untracked", &untracked,
                        "search in both tracked and untracked files"),
                OPT_SET_INT(0, "exclude-standard", &opt_exclude,
@@ -923,8 +919,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 
 #ifndef NO_PTHREADS
        if (use_threads) {
-               if (opt.pre_context || opt.post_context || opt.file_break ||
-                   opt.funcbody)
+               if (!(opt.name_only || opt.unmatch_name_only || opt.count)
+                   && (opt.pre_context || opt.post_context ||
+                       opt.file_break || opt.funcbody))
                        skip_first_line = 1;
                start_threads(&opt);
        }