git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] format-patch: allow --rfc to optionally take a value, like --rfc=WIP

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 19, 2024, 17:03 UTC
Message-ID
<xmqq1q71l1xz.fsf@gitster.g>
In-Reply-To
<9f846a3d-5244-43ec-b392-156665be0929@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 5 quoted lines
>> -		   [--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.
Show 11 quoted lines
>> @@ -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' '
Previous: Phillip WoodNext: Dragan Simic
Message 4 of 24 in “format-patch: allow --rfc to optionally take a value, like --rfc=WIP”
  1. format-patch: allow --rfc to optionally take a value, like --rfc=WIPJunio C Hamano, Apr 18, 2024
  2. Dragan SimicApr 19, 2024
  3. Phillip WoodApr 19, 2024
  4. Junio C HamanoApr 19, 2024
  5. Dragan SimicApr 21, 2024
  6. Jeff KingApr 19, 2024
  7. Junio C HamanoApr 19, 2024
  8. format-patch: allow --rfc to optionally take a value, like --rfc=WIPJunio C Hamano, Apr 19, 2024
  9. Phillip WoodApr 21, 2024
  10. Junio C HamanoApr 21, 2024
  11. 0/2 format-patch --rfc=WIPJunio C Hamano, Apr 21, 2024
  12. 2/2 format-patch: "--rfc=-(WIP)" appends to produce [PATCH (WIP)]Junio C Hamano, Apr 21, 2024
  13. Dragan SimicApr 21, 2024
  14. Phillip WoodApr 24, 2024
  15. Dragan SimicApr 24, 2024
  16. 1/2 format-patch: allow --rfc to optionally take a value, like --rfc=WIPJunio C Hamano, Apr 21, 2024
  17. 0/2 format-patch --rfc=WIPJunio C Hamano, Apr 23, 2024
  18. 1/2 format-patch: allow --rfc to optionally take a value, like --rfc=WIPJunio C Hamano, Apr 23, 2024
  19. Phillip WoodApr 24, 2024
  20. 2/2 format-patch: "--rfc=-(WIP)" appends to produce [PATCH (WIP)]Junio C Hamano, Apr 23, 2024
  21. Phillip WoodApr 24, 2024
  22. Junio C HamanoApr 24, 2024
  23. Dragan SimicApr 24, 2024
  24. Dragan SimicApr 24, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.