Skip to content

Commit c62cd17

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6f1a5ca commit c62cd17

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

add-interactive.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
4444
init_color(r, s, "help", s->help_color, GIT_COLOR_BOLD_RED);
4545
init_color(r, s, "prompt", s->prompt_color, GIT_COLOR_BOLD_BLUE);
4646
init_color(r, s, "error", s->error_color, GIT_COLOR_BOLD_RED);
47-
init_color(r, s, "reset", s->reset_color, GIT_COLOR_RESET);
4847
init_color(r, s, "fraginfo", s->fraginfo_color,
4948
diff_get_color(s->use_color, DIFF_FRAGINFO));
5049
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)
5453
init_color(r, s, "new", s->file_new_color,
5554
diff_get_color(s->use_color, DIFF_FILE_NEW));
5655

56+
strlcpy(s->reset_color,
57+
s->use_color ? GIT_COLOR_RESET : "", COLOR_MAXLEN);
58+
5759
FREE_AND_NULL(s->interactive_diff_filter);
5860
git_config_get_string("interactive.difffilter",
5961
&s->interactive_diff_filter);

0 commit comments

Comments
 (0)