Skip to content

Commit 25d9e5c

Browse files
dschopeff
authored andcommitted
add -i (built-in): use correct names to load color.diff.* config
The builtin version of add-interactive mistakenly loads diff colors from color.interactive.* instead of color.diff.*. It also accidentally spells `frag` as `fraginfo`. Let's fix that. Note also that we don't respect the historical `diff.color.*`. The perl version never did, and those have been deprecated since 2007. Reported-by: Philippe Blain <[email protected]> Co-authored-by: Jeff King <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c62cd17 commit 25d9e5c

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

add-interactive.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
#include "prompt.h"
1313

1414
static void init_color(struct repository *r, struct add_i_state *s,
15-
const char *slot_name, char *dst,
15+
const char *section_and_slot, char *dst,
1616
const char *default_color)
1717
{
18-
char *key = xstrfmt("color.interactive.%s", slot_name);
18+
char *key = xstrfmt("color.%s", section_and_slot);
1919
const char *value;
2020

2121
if (!s->use_color)
@@ -40,17 +40,20 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
4040
git_config_colorbool("color.interactive", value);
4141
s->use_color = want_color(s->use_color);
4242

43-
init_color(r, s, "header", s->header_color, GIT_COLOR_BOLD);
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, "fraginfo", s->fraginfo_color,
43+
init_color(r, s, "interactive.header", s->header_color, GIT_COLOR_BOLD);
44+
init_color(r, s, "interactive.help", s->help_color, GIT_COLOR_BOLD_RED);
45+
init_color(r, s, "interactive.prompt", s->prompt_color,
46+
GIT_COLOR_BOLD_BLUE);
47+
init_color(r, s, "interactive.error", s->error_color,
48+
GIT_COLOR_BOLD_RED);
49+
50+
init_color(r, s, "diff.frag", s->fraginfo_color,
4851
diff_get_color(s->use_color, DIFF_FRAGINFO));
49-
init_color(r, s, "context", s->context_color,
52+
init_color(r, s, "diff.context", s->context_color,
5053
diff_get_color(s->use_color, DIFF_CONTEXT));
51-
init_color(r, s, "old", s->file_old_color,
54+
init_color(r, s, "diff.old", s->file_old_color,
5255
diff_get_color(s->use_color, DIFF_FILE_OLD));
53-
init_color(r, s, "new", s->file_new_color,
56+
init_color(r, s, "diff.new", s->file_new_color,
5457
diff_get_color(s->use_color, DIFF_FILE_NEW));
5558

5659
strlcpy(s->reset_color,

0 commit comments

Comments
 (0)