Subject: Re: [RFC PATCH 2/3] strbuf_commented_addf(): drop the comment_line_char parameter

From: Junio C Hamano <[email-masked]>
Date: Tue, 31 Oct 2023 14:19:31 +0900

Jonathan Tan <[email-masked]> writes:

> From: Junio C Hamano <[email-masked]>
>
> 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 <[email-masked]>
> Signed-off-by: Jonathan Tan <[email-masked]>
> ---

> 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.