From: Phillip Wood Date: Fri, 13 Nov 2020 12:07:47 GMT Subject: Re: [PATCH v2 07/11] add -p (built-in): do not color the progress indicator separately Message-ID: <918a0a1d-6384-5615-c343-1f03046770f7@gmail.com> In-Reply-To: <73b6d60a801766605cde9403d7a9e8451ef99e11.1605097704.git.gitgitgadget@gmail.com> Hi Dscho On 11/11/2020 12:28, Johannes Schindelin via GitGitGadget wrote: > From: Johannes Schindelin > > 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. Why? the C version has access to an api that means we don't have to remember to print the reset string each time so why move away from that? I don't think it matters to the user that there are some extra escape codes in the prompt of the C version. The answer is probably "so we can use the same test as the perl version" which might be a good reason - if it is I think it would be helpful to say so in the commit message. Best Wishes Phillip > Signed-off-by: Johannes Schindelin > --- > add-patch.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > 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, > 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; >