]> git.ipfire.org Git - thirdparty/git.git/commitdiff
built-in add -p: color the prompt and the help text
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 13 Dec 2019 08:07:52 +0000 (08:07 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Dec 2019 20:37:13 +0000 (12:37 -0800)
... just like the Perl version ;-)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
add-patch.c

index e266a96ca7826e07a397ccc22ae9eb394a830fd9..dab2ff2381f0642488db2ebd79f0e4083ce0d97e 100644 (file)
@@ -334,9 +334,12 @@ static int patch_update_file(struct add_p_state *s)
                        strbuf_addstr(&s->buf, ",j");
                if (hunk_index + 1 < s->hunk_nr)
                        strbuf_addstr(&s->buf, ",J");
-               printf("(%"PRIuMAX"/%"PRIuMAX") ",
-                      (uintmax_t)hunk_index + 1, (uintmax_t)s->hunk_nr);
-               printf(_("Stage this hunk [y,n,a,d%s,?]? "), s->buf.buf);
+               color_fprintf(stdout, s->s.prompt_color,
+                             "(%"PRIuMAX"/%"PRIuMAX") ",
+                             (uintmax_t)hunk_index + 1, (uintmax_t)s->hunk_nr);
+               color_fprintf(stdout, s->s.prompt_color,
+                             _("Stage this hunk [y,n,a,d%s,?]? "),
+                             s->buf.buf);
                fflush(stdout);
                if (strbuf_getline(&s->answer, stdin) == EOF)
                        break;
@@ -376,7 +379,8 @@ soft_increment:
                else if (undecided_next >= 0 && s->answer.buf[0] == 'j')
                        hunk_index = undecided_next;
                else
-                       puts(_(help_patch_text));
+                       color_fprintf(stdout, s->s.help_color,
+                                     _(help_patch_text));
        }
 
        /* Any hunk to be used? */