All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org,  Phillip Wood <phillip.wood123@gmail.com>,
	 Dragan Simic <dsimic@manjaro.org>
Subject: Re: [RFC PATCH 2/3] strbuf_commented_addf(): drop the comment_line_char parameter
Date: Tue, 31 Oct 2023 14:19:31 +0900	[thread overview]
Message-ID: <xmqqh6m74bdo.fsf@gitster.g> (raw)
In-Reply-To: <bb01336233b30d46960d6eb15f036e6346a9cd2b.1698696798.git.jonathantanmy@google.com> (Jonathan Tan's message of "Mon, 30 Oct 2023 13:22:47 -0700")

Jonathan Tan <jonathantanmy@google.com> writes:

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

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

  reply	other threads:[~2023-10-31  5:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-30  5:10 [PATCH 0/2] Avoid passing global comment_line_char repeatedly Junio C Hamano
2023-10-30  5:10 ` [PATCH 1/2] strbuf_commented_addf(): drop the comment_line_char parameter Junio C Hamano
2023-10-30  5:10 ` [PATCH 2/2] strbuf_add_commented_lines(): " Junio C Hamano
2023-10-30  5:36 ` [PATCH 0/2] Avoid passing global comment_line_char repeatedly Dragan Simic
2023-10-30  9:59 ` Phillip Wood
2023-10-30 20:22   ` [RFC PATCH 0/3] " Jonathan Tan
2023-10-30 20:22     ` [RFC PATCH 1/3] strbuf: make add_lines() public Jonathan Tan
2023-10-30 23:53       ` Junio C Hamano
2023-10-31  6:01         ` Junio C Hamano
2023-10-30 20:22     ` [RFC PATCH 2/3] strbuf_commented_addf(): drop the comment_line_char parameter Jonathan Tan
2023-10-31  5:19       ` Junio C Hamano [this message]
2023-10-31 22:24         ` Jonathan Tan
2023-10-31 23:54           ` Junio C Hamano
2023-10-30 20:22     ` [RFC PATCH 3/3] strbuf_add_commented_lines(): " Jonathan Tan
2023-10-31 22:28   ` [PATCH v2 0/4] Avoid passing global comment_line_char repeatedly Jonathan Tan
2023-10-31 22:28     ` [PATCH v2 1/4] strbuf_commented_addf(): drop the comment_line_char parameter Jonathan Tan
2023-10-31 22:28     ` [PATCH v2 2/4] strbuf_add_commented_lines(): " Jonathan Tan
2023-10-31 22:28     ` [PATCH v2 3/4] strbuf: make add_lines() public Jonathan Tan
2023-11-01  4:14       ` Junio C Hamano
2023-10-31 22:28     ` [PATCH v2 4/4] strbuf: move env-using functions to environment.c Jonathan Tan
2023-11-01  4:37       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqh6m74bdo.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=dsimic@manjaro.org \
    --cc=git@vger.kernel.org \
    --cc=jonathantanmy@google.com \
    --cc=phillip.wood123@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.