Skip to content

Commit

Permalink
add -i (built-in): prevent the reset "color" from being configured
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dscho authored and gitster committed Nov 11, 2020
1 parent 6f1a5ca commit c62cd17
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion add-interactive.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
init_color(r, s, "help", s->help_color, GIT_COLOR_BOLD_RED);
init_color(r, s, "prompt", s->prompt_color, GIT_COLOR_BOLD_BLUE);
init_color(r, s, "error", s->error_color, GIT_COLOR_BOLD_RED);
init_color(r, s, "reset", s->reset_color, GIT_COLOR_RESET);
init_color(r, s, "fraginfo", s->fraginfo_color,
diff_get_color(s->use_color, DIFF_FRAGINFO));
init_color(r, s, "context", s->context_color,
Expand All @@ -54,6 +53,9 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
init_color(r, s, "new", s->file_new_color,
diff_get_color(s->use_color, DIFF_FILE_NEW));

strlcpy(s->reset_color,
s->use_color ? GIT_COLOR_RESET : "", COLOR_MAXLEN);

FREE_AND_NULL(s->interactive_diff_filter);
git_config_get_string("interactive.difffilter",
&s->interactive_diff_filter);
Expand Down

0 comments on commit c62cd17

Please sign in to comment.