Re: [RFC PATCH 2/3] strbuf_commented_addf(): drop the comment_line_char parameter
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 31, 2023, 05:19 UTC
- Message-ID
- <xmqqh6m74bdo.fsf@gitster.g>
- In-Reply-To
- <bb01336233b30d46960d6eb15f036e6346a9cd2b.1698696798.git.jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 10 quoted lines
> From: Junio C Hamano <gitster@pobox.com> > > All the callers of this function supply the global variable > comment_line_char as an argument to its second parameter. Remove > the parameter to allow us in the future to change the reference to > the global variable with something else, like a function call. > > Signed-off-by: Junio C Hamano <gitster@pobox.com> > Signed-off-by: Jonathan Tan <jonathantanmy@google.com> > ---
Show 26 quoted lines
> diff --git a/environment.c b/environment.c
> index bb3c2a96a3..d9f64cffa0 100644
> --- a/environment.c
> +++ b/environment.c
> @@ -416,3 +416,21 @@ int print_sha1_ellipsis(void)
> }
> return cached_result;
> }
> +
> +void strbuf_commented_addf(struct strbuf *sb,
> + const char *fmt, ...)
> +{
> + va_list params;
> + struct strbuf buf = STRBUF_INIT;
> + int incomplete_line = sb->len && sb->buf[sb->len - 1] != '\n';
> +
> + va_start(params, fmt);
> + strbuf_vaddf(&buf, fmt, params);
> + va_end(params);
> +
> + strbuf_add_commented_lines(sb, buf.buf, buf.len, comment_line_char);
> + if (incomplete_line)
> + sb->buf[--sb->len] = '\0';
> +
> + strbuf_release(&buf);
> +}This moving of the helper function does not belong to the "fix commented_addf() not to take the comment_line_char" step.
The series should be restructured to have the two patches from me first, and then your moving some stuff to environment.c, probably.