git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Drew DeVault <sir@cmpwn.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v4] format-patch: --rfc honors what --subject-prefix sets
Date: Wed, 30 Aug 2023 12:28:15 -0700	[thread overview]
Message-ID: <xmqqsf808h4g.fsf@gitster.g> (raw)
In-Reply-To: <20230830064646.30904-1-sir@cmpwn.com> (Drew DeVault's message of "Wed, 30 Aug 2023 08:43:33 +0200")

Drew DeVault <sir@cmpwn.com> writes:

> Minor correction to the documentation is also included, and a second
> test just for good measure which demonstrates that the order of
> arguments no longer important.

Perfect.

>  Documentation/git-format-patch.txt | 18 +++++++++++------
>  builtin/log.c                      | 31 +++++++++++++++---------------
>  t/t4014-format-patch.sh            | 22 ++++++++++++++++++++-
>  3 files changed, 48 insertions(+), 23 deletions(-)
>
> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
> index 373b46fc0d..b96e142a8d 100644
> --- a/Documentation/git-format-patch.txt
> +++ b/Documentation/git-format-patch.txt
> @@ -217,9 +217,15 @@ populated with placeholder text.
>  
>  --subject-prefix=<subject prefix>::
>  	Instead of the standard '[PATCH]' prefix in the subject
> -	line, instead use '[<subject prefix>]'. This
> -	allows for useful naming of a patch series, and can be
> -	combined with the `--numbered` option.
> +	line, instead use '[<subject prefix>]'. This can be used
> +	to name a patch series, and can be combined with the
> +	`--numbered` option.
> ++
> +The configuration variable `format.subjectPrefix` may also be used
> +to to configure a subject prefix to apply to a given repository for
> +all patches. This is often useful on mailing lists which receive
> +patches for several repositories and can be used to disambiguate
> +the patches (with a value of e.g. "PATCH my-project").

Nice.

I'll locally fix "to to" -> "to" while queuing; no need to reroll
only to fix this.

> diff --git a/builtin/log.c b/builtin/log.c
> index db3a88bfe9..29c86dc798 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -1468,19 +1468,16 @@ static int subject_prefix = 0;
>  static int subject_prefix_callback(const struct option *opt, const char *arg,
>  			    int unset)
>  {
> +	struct strbuf *sprefix;
> +
>  	BUG_ON_OPT_NEG(unset);
> +	sprefix = (struct strbuf *)opt->value;
>  	subject_prefix = 1;
> -	((struct rev_info *)opt->value)->subject_prefix = arg;
> +	strbuf_reset(sprefix);
> +	strbuf_addstr(sprefix, arg);
>  	return 0;
>  }

OK.

> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> index 3cf2b7a7fb..9fa1f3bc7a 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -1373,7 +1373,27 @@ test_expect_success '--rfc' '
>  	Subject: [RFC PATCH 1/1] header with . in it
>  	EOF
>  	git format-patch -n -1 --stdout --rfc >patch &&
> -	grep ^Subject: patch >actual &&
> +	grep "^Subject:" patch >actual &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success '--rfc does not overwrite prefix' '
> +	cat >expect <<-\EOF &&
> +	Subject: [RFC PATCH foobar 1/1] header with . in it
> +	EOF
> +	git -c format.subjectPrefix="PATCH foobar" \
> +		format-patch -n -1 --stdout --rfc >patch &&
> +	grep "^Subject:" patch >actual &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success '--rfc is argument order independent' '
> +	cat >expect <<-\EOF &&
> +	Subject: [RFC PATCH foobar 1/1] header with . in it
> +	EOF
> +	git format-patch -n -1 --stdout --rfc \
> +		--subject-prefix="PATCH foobar" >patch &&
> +	grep "^Subject:" patch >actual &&
>  	test_cmp expect actual
>  '

Nice.

Will queue.  Let's wait to see if others find something fishy for a
day or two and then merge it down to 'next'.

Thanks.

  reply	other threads:[~2023-08-30 20:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30  6:43 [PATCH v4] format-patch: --rfc honors what --subject-prefix sets Drew DeVault
2023-08-30 19:28 ` Junio C Hamano [this message]
2023-08-31 21:29   ` Jeff King
2023-08-31 22:04     ` Junio C Hamano
2023-08-31 22:32       ` Jeff King
2023-09-01  7:29       ` Drew DeVault
2023-09-01 16:48         ` 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=xmqqsf808h4g.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=sir@cmpwn.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).