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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Phillip Wood <phillip.wood123@xxxxxxxxx> 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' '




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux