From: Junio C Hamano Date: Tue, 3 Jun 2014 19:06:39 +0000 (-0700) Subject: Merge branch 'as/grep-fullname-config' X-Git-Tag: v2.1.0-rc0~203 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/52df9173fa9b409a96c02a62b06d2b19f4ff5d0f?ds=inline;hp=-c Merge branch 'as/grep-fullname-config' Add a configuration variable to force --full-name to be default for "git grep". This may cause regressions on scripted users that do not expect this new behaviour. * as/grep-fullname-config: grep: add grep.fullName config variable --- 52df9173fa9b409a96c02a62b06d2b19f4ff5d0f diff --combined grep.c index 4aef0a69d0,ece04bf275..99217dc04f --- a/grep.c +++ b/grep.c @@@ -86,6 -86,11 +86,11 @@@ int grep_config(const char *var, const 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")) @@@ -1562,11 -1567,8 +1567,11 @@@ static int grep_source_1(struct grep_op */ 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; @@@ -1653,7 -1655,7 +1658,7 @@@ void grep_source_init(struct grep_sourc 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;