]> git.ipfire.org Git - thirdparty/git.git/commitdiff
add -p (built-in): do not color the progress indicator separately
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 16 Nov 2020 16:08:28 +0000 (16:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Nov 2020 23:59:02 +0000 (15:59 -0800)
The Perl version of this command colors the progress indicator and the
prompt message in one go.

Let's do the same in the built-in version so that the same upcoming test
(which will compare the output of `git add -p` against a known-good
version) will pass both for the Perl version as well as for the built-in
version.

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

index 1db674414b33a0266932a982854fd647d0f0b71e..8ad0937e6c34ce47126f4d19651ed79942d4e7e2 100644 (file)
@@ -1461,15 +1461,15 @@ static int patch_update_file(struct add_p_state *s,
                else
                        prompt_mode_type = PROMPT_HUNK;
 
-               color_fprintf(stdout, s->s.prompt_color,
-                             "(%"PRIuMAX"/%"PRIuMAX") ",
+               printf("%s(%"PRIuMAX"/%"PRIuMAX") ", s->s.prompt_color,
                              (uintmax_t)hunk_index + 1,
                              (uintmax_t)(file_diff->hunk_nr
                                                ? file_diff->hunk_nr
                                                : 1));
-               color_fprintf(stdout, s->s.prompt_color,
-                             _(s->mode->prompt_mode[prompt_mode_type]),
-                             s->buf.buf);
+               printf(_(s->mode->prompt_mode[prompt_mode_type]),
+                      s->buf.buf);
+               if (*s->s.reset_color)
+                       fputs(s->s.reset_color, stdout);
                fflush(stdout);
                if (read_single_character(s) == EOF)
                        break;