]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-grep.c
lib-patch-mode.sh: Fix permission
[git.git] / builtin-grep.c
index 037452ec79475244f4cae7cfc936695e1de58a63..f477659100fdc63bff5938b4c96f28eaefc07460 100644 (file)
@@ -11,6 +11,7 @@
 #include "tree-walk.h"
 #include "builtin.h"
 #include "parse-options.h"
+#include "userdiff.h"
 #include "grep.h"
 
 #ifndef NO_EXTERNAL_GREP
@@ -30,6 +31,12 @@ static int grep_config(const char *var, const char *value, void *cb)
 {
        struct grep_opt *opt = cb;
 
+       switch (userdiff_config(var, value)) {
+       case 0: break;
+       case -1: return -1;
+       default: return 0;
+       }
+
        if (!strcmp(var, "color.grep")) {
                opt->color = git_config_colorbool(var, value, -1);
                return 0;
@@ -278,13 +285,13 @@ static int flush_grep(struct grep_opt *opt,
                argc -= 2;
        }
 
-       if (opt->pre_context || opt->post_context || opt->funcname) {
+       if (opt->pre_context || opt->post_context) {
                /*
                 * grep handles hunk marks between files, but we need to
                 * do that ourselves between multiple calls.
                 */
                if (opt->show_hunk_mark)
-                       write_or_die(1, opt->funcname ? "==\n" : "--\n", 3);
+                       write_or_die(1, "--\n", 3);
                else
                        opt->show_hunk_mark = 1;
        }
@@ -605,7 +612,7 @@ static int file_callback(const struct option *opt, const char *arg, int unset)
 
        patterns = fopen(arg, "r");
        if (!patterns)
-               die("'%s': %s", arg, strerror(errno));
+               die_errno("cannot open '%s'", arg);
        while (strbuf_getline(&sb, patterns, '\n') == 0) {
                /* ignore empty line like grep does */
                if (sb.len == 0)