add -i (built-in): prevent the `reset` "color" from being configured
The Perl version of that command sneakily uses `git config --get-color` to figure out the ANSI sequence to reset the color, but passes the empty string and therefore cannot actually match any config entry. This was missed when re-implementing the command as a built-in command. Let's fix this, preventing the `reset` sequence from being overridden via the config. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Nov 11, 2020 at 12:28 UTC
c62cd1720f5c9cf57955a78576ba7e862b7352e6
1 file changed
+3
-1
add-interactive.c
+3
-1
@@ -44,7 +44,6 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
44
init_color(r, s, "help", s->help_color, GIT_COLOR_BOLD_RED);
45
init_color(r, s, "prompt", s->prompt_color, GIT_COLOR_BOLD_BLUE);
46
init_color(r, s, "error", s->error_color, GIT_COLOR_BOLD_RED);
47
- init_color(r, s, "reset", s->reset_color, GIT_COLOR_RESET);
47
init_color(r, s, "fraginfo", s->fraginfo_color,
48
diff_get_color(s->use_color, DIFF_FRAGINFO));
49
init_color(r, s, "context", s->context_color,
@@ -54,6 +53,9 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
53
init_color(r, s, "new", s->file_new_color,
54
diff_get_color(s->use_color, DIFF_FILE_NEW));
55
56
+ strlcpy(s->reset_color,
57
+ s->use_color ? GIT_COLOR_RESET : "", COLOR_MAXLEN);
58
+
59
FREE_AND_NULL(s->interactive_diff_filter);
60
git_config_get_string("interactive.difffilter",
61
&s->interactive_diff_filter);