Skip to content

Commit bd92652

Browse files
committed
built-in add -p: color the prompt and the help text
... just like the Perl version ;-) Note that this requires the `get_add_i_color()` function being defined globally, which is the entire reason why we gave it such a descriptive name in the first place. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 23cbcb5 commit bd92652

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

add-interactive.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ struct add_i_state {
1616

1717
int init_add_i_state(struct repository *r, struct add_i_state *s);
1818

19+
enum color_add_i {
20+
COLOR_HEADER = 0,
21+
COLOR_HELP,
22+
COLOR_PROMPT,
23+
COLOR_ERROR,
24+
COLOR_RESET,
25+
};
26+
const char *get_add_i_color(enum color_add_i ix);
27+
1928
struct repository;
2029
struct pathspec;
2130
int run_add_i(struct repository *r, const struct pathspec *ps);

add-patch.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ static int patch_update_file(struct add_p_state *s)
331331
strbuf_addstr(&s->buf, ",j");
332332
if (hunk_index + 1 < s->hunk_nr)
333333
strbuf_addstr(&s->buf, ",J");
334-
printf(_("Stage this hunk [y,n,a,d%s,?]? "), s->buf.buf);
334+
color_fprintf(stdout, s->s.prompt_color,
335+
_("Stage this hunk [y,n,a,d%s,?]? "),
336+
s->buf.buf);
335337
fflush(stdout);
336338
if (strbuf_getline(&s->answer, stdin) == EOF)
337339
break;
@@ -373,7 +375,8 @@ static int patch_update_file(struct add_p_state *s)
373375
else if (undecided_next >= 0 && s->answer.buf[0] == 'j')
374376
hunk_index = undecided_next;
375377
else
376-
puts(_(help_patch_text));
378+
color_fprintf(stdout, s->s.help_color,
379+
_(help_patch_text));
377380
}
378381

379382
/* Any hunk to be used? */

0 commit comments

Comments
 (0)