diff mbox series

[v3,07/11] add -p (built-in): do not color the progress indicator separately

Message ID 6a68bc5511a72d25b84a243dd5d8019f81cee610.1605542912.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Fix color handling in git add -i | expand

Commit Message

Johannes Schindelin Nov. 16, 2020, 4:08 p.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
 add-patch.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series


diff --git a/add-patch.c b/add-patch.c
index bf89c43145..2fad92ca37 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1461,15 +1461,15 @@  static int patch_update_file(struct add_p_state *s,
 			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,
 						? 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);
 		if (read_single_character(s) == EOF)