add -p (built-in): do not color the progress indicator separately

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>

Johannes Schindelin committed Nov 16, 2020 at 16:08 UTC 6681e3603216f0e279fea467a0e6d829fffb82a5
1 file changed +5 -5
add-patch.c
+5 -5
@@ -1461,15 +1461,15 @@ static int patch_update_file(struct add_p_state *s,
1461 else
1462 prompt_mode_type = PROMPT_HUNK;
1463
1464 - color_fprintf(stdout, s->s.prompt_color,
1465 - "(%"PRIuMAX"/%"PRIuMAX") ",
1464 + printf("%s(%"PRIuMAX"/%"PRIuMAX") ", s->s.prompt_color,
1465 (uintmax_t)hunk_index + 1,
1466 (uintmax_t)(file_diff->hunk_nr
1467 ? file_diff->hunk_nr
1468 : 1));
1470 - color_fprintf(stdout, s->s.prompt_color,
1471 - _(s->mode->prompt_mode[prompt_mode_type]),
1472 - s->buf.buf);
1469 + printf(_(s->mode->prompt_mode[prompt_mode_type]),
1470 + s->buf.buf);
1471 + if (*s->s.reset_color)
1472 + fputs(s->s.reset_color, stdout);
1473 fflush(stdout);
1474 if (read_single_character(s) == EOF)
1475 break;