add_excludes_from_file: clarify the bom skipping logic
[gitweb.git] / grep.c
diff --git a/grep.c b/grep.c
index f950651ae61e80cd57c6d224a461313d14cb320d..6e085f829731146c319fff57da0ae482de97ff77 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -87,6 +87,11 @@ int grep_config(const char *var, const char *value, void *cb)
                return 0;
        }
 
+       if (!strcmp(var, "grep.fullname")) {
+               opt->relative = !git_config_bool(var, value);
+               return 0;
+       }
+
        if (!strcmp(var, "color.grep"))
                opt->color = git_config_colorbool(var, value);
        else if (!strcmp(var, "color.grep.context"))
@@ -109,15 +114,15 @@ int grep_config(const char *var, const char *value, void *cb)
                int rc = 0;
                if (!value)
                        return config_error_nonbool(var);
-               color_parse(value, var, opt->color_match_context);
-               color_parse(value, var, opt->color_match_selected);
+               rc |= color_parse(value, opt->color_match_context);
+               rc |= color_parse(value, opt->color_match_selected);
                return rc;
        }
 
        if (color) {
                if (!value)
                        return config_error_nonbool(var);
-               color_parse(value, var, color);
+               return color_parse(value, color);
        }
        return 0;
 }
@@ -1577,8 +1582,11 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle
         */
        if (opt->count && count) {
                char buf[32];
-               output_color(opt, gs->name, strlen(gs->name), opt->color_filename);
-               output_sep(opt, ':');
+               if (opt->pathname) {
+                       output_color(opt, gs->name, strlen(gs->name),
+                                    opt->color_filename);
+                       output_sep(opt, ':');
+               }
                snprintf(buf, sizeof(buf), "%u\n", count);
                opt->output(opt, buf, strlen(buf));
                return 1;
@@ -1665,7 +1673,7 @@ void grep_source_init(struct grep_source *gs, enum grep_source_type type,
                break;
        case GREP_SOURCE_SHA1:
                gs->identifier = xmalloc(20);
-               memcpy(gs->identifier, identifier, 20);
+               hashcpy(gs->identifier, identifier);
                break;
        case GREP_SOURCE_BUF:
                gs->identifier = NULL;