From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: git@vger.kernel.org, Dragan Simic <dsimic@manjaro.org>
Subject: Re: [PATCH] format-patch: allow --rfc to optionally take a value, like --rfc=WIP
Date: Fri, 19 Apr 2024 10:03:36 -0700 [thread overview]
Message-ID: <xmqq1q71l1xz.fsf@gitster.g> (raw)
In-Reply-To: <9f846a3d-5244-43ec-b392-156665be0929@gmail.com> (Phillip Wood's message of "Fri, 19 Apr 2024 15:09:54 +0100")
Phillip Wood <phillip.wood123@gmail.com> writes:
>> - [--rfc] [--subject-prefix=<subject-prefix>]
>> + [--rfc[=<rfc>]] [--subject-prefix=<subject-prefix>]
>
> Nit: in the documentation we use "<rfc>" for the placeholder but in
> the code we use "<extra>"
You're right. Will fix.
>> @@ -1932,7 +1944,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>> N_("mark the series as Nth re-roll")),
>> OPT_INTEGER(0, "filename-max-length", &fmt_patch_name_max,
>> N_("max length of output filename")),
>> - OPT_BOOL(0, "rfc", &rfc, N_("use [RFC PATCH] instead of [PATCH]")),
>> + OPT_CALLBACK_F(0, "rfc", &rfc, N_("extra"),
>> + N_("add <extra> (default 'RFC') before 'PATCH'"),
>> + PARSE_OPT_NONEG|PARSE_OPT_OPTARG, rfc_callback),
>
> This is a change in behavior as it looks like we previously accepted
> "--no-rfc" is that deliberate?
I just matched the subject-prefix without thinking. Will fix.
Here is what I plan to squash in, but we are about to enter the
pre-release stabilization period, so the progress on this new
feature will have to slow down.
Thanks.
builtin/log.c | 10 +++++-----
t/t4014-format-patch.sh | 16 ++++++++++++----
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git i/builtin/log.c w/builtin/log.c
index 2d6e0f3688..0e9c84e51d 100644
--- i/builtin/log.c
+++ w/builtin/log.c
@@ -1499,10 +1499,10 @@ static int rfc_callback(const struct option *opt, const char *arg,
{
struct strbuf *rfc;
- BUG_ON_OPT_NEG(unset);
rfc = opt->value;
strbuf_reset(rfc);
- strbuf_addstr(rfc, arg ? arg : "RFC");
+ if (!unset)
+ strbuf_addstr(rfc, arg ? arg : "RFC");
return 0;
}
@@ -1944,9 +1944,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
N_("mark the series as Nth re-roll")),
OPT_INTEGER(0, "filename-max-length", &fmt_patch_name_max,
N_("max length of output filename")),
- OPT_CALLBACK_F(0, "rfc", &rfc, N_("extra"),
- N_("add <extra> (default 'RFC') before 'PATCH'"),
- PARSE_OPT_NONEG|PARSE_OPT_OPTARG, rfc_callback),
+ OPT_CALLBACK_F(0, "rfc", &rfc, N_("rfc"),
+ N_("add <rfc> (default 'RFC') before 'PATCH'"),
+ PARSE_OPT_OPTARG, rfc_callback),
OPT_STRING(0, "cover-from-description", &cover_from_description_arg,
N_("cover-from-description-mode"),
N_("generate parts of a cover letter based on a branch's description")),
diff --git i/t/t4014-format-patch.sh w/t/t4014-format-patch.sh
index 905858da35..645c4189f9 100755
--- i/t/t4014-format-patch.sh
+++ w/t/t4014-format-patch.sh
@@ -1368,22 +1368,30 @@ test_expect_success 'empty subject prefix does not have extra space' '
test_cmp expect actual
'
-test_expect_success '--rfc' '
+test_expect_success '--rfc and --no-rfc' '
cat >expect <<-\EOF &&
Subject: [RFC PATCH 1/1] header with . in it
EOF
git format-patch -n -1 --stdout --rfc >patch &&
grep "^Subject:" patch >actual &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ git format-patch -n -1 --stdout --rfc --no-rfc >patch &&
+ sed -e "s/RFC //" expect >expect-raw &&
+ grep "^Subject:" patch >actual &&
+ test_cmp expect-raw actual
'
-test_expect_success '--rfc=WIP' '
+test_expect_success '--rfc=WIP and --rfc=' '
cat >expect <<-\EOF &&
Subject: [WIP PATCH 1/1] header with . in it
EOF
git format-patch -n -1 --stdout --rfc=WIP >patch &&
grep "^Subject:" patch >actual &&
- test_cmp expect actual
+ test_cmp expect actual &&
+ git format-patch -n -1 --stdout --rfc --rfc= >patch &&
+ sed -e "s/WIP //" expect >expect-raw &&
+ grep "^Subject:" patch >actual &&
+ test_cmp expect-raw actual
'
test_expect_success '--rfc does not overwrite prefix' '
next prev parent reply other threads:[~2024-04-19 17:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-18 22:54 [PATCH] format-patch: allow --rfc to optionally take a value, like --rfc=WIP Junio C Hamano
2024-04-19 0:29 ` Dragan Simic
2024-04-19 14:09 ` Phillip Wood
2024-04-19 17:03 ` Junio C Hamano [this message]
2024-04-21 14:18 ` Dragan Simic
2024-04-19 18:00 ` Jeff King
2024-04-19 18:19 ` Junio C Hamano
2024-04-19 22:01 ` [PATCH v2] " Junio C Hamano
2024-04-21 15:41 ` Phillip Wood
2024-04-21 18:58 ` Junio C Hamano
2024-04-21 18:59 ` [PATCH v3 0/2] format-patch --rfc=WIP Junio C Hamano
2024-04-21 18:59 ` [PATCH v3 1/2] format-patch: allow --rfc to optionally take a value, like --rfc=WIP Junio C Hamano
2024-04-21 18:59 ` [PATCH v3 2/2] format-patch: "--rfc=-(WIP)" appends to produce [PATCH (WIP)] Junio C Hamano
2024-04-21 19:37 ` Dragan Simic
2024-04-24 10:17 ` Phillip Wood
2024-04-24 15:52 ` Dragan Simic
2024-04-23 17:52 ` [PATCH v4 0/2] format-patch --rfc=WIP Junio C Hamano
2024-04-23 17:52 ` [PATCH v4 1/2] format-patch: allow --rfc to optionally take a value, like --rfc=WIP Junio C Hamano
2024-04-24 10:16 ` Phillip Wood
2024-04-23 17:52 ` [PATCH v4 2/2] format-patch: "--rfc=-(WIP)" appends to produce [PATCH (WIP)] Junio C Hamano
2024-04-24 10:16 ` Phillip Wood
2024-04-24 15:25 ` Junio C Hamano
2024-04-24 16:34 ` Dragan Simic
2024-04-24 15:58 ` Dragan Simic
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=xmqq1q71l1xz.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=dsimic@manjaro.org \
--cc=git@vger.kernel.org \
--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 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 read-only IMAP folder(s) and NNTP newsgroup(s).