aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-04-23 10:52:33 -0700
committerJunio C Hamano <gitster@pobox.com>2024-04-23 11:00:38 -0700
commitce48fb2eabccc269443f33d0f148d0061b94a101 (patch)
treeb681fd58ca5d10c4080de3fb537f219ee89fa4a3 /t
parent21306a098c3f174ad4c2a5cddb9069ee27a548b0 (diff)
downloadgit-ce48fb2eabccc269443f33d0f148d0061b94a101.tar.gz
format-patch: allow --rfc to optionally take a value, like --rfc=WIP
With the "--rfc" option, we can tweak the "[PATCH]" (or whatever string specified with the "--subject-prefix" option, instead of "PATCH") that we prefix the title of the commit with into "[RFC PATCH]", but some projects may want "[rfc PATCH]". Adding a new option, e.g., "--rfc-lowercase", to support such need every time somebody wants to use different strings would lead to insanity of accumulating unbounded number of such options. Allow an optional value specified for the option, so that users can use "--rfc=rfc" (think of "--rfc" without value as a short-hand for "--rfc=RFC") if they wanted to. This can of course be (ab)used to make the prefix "[WIP PATCH]" by passing "--rfc=WIP". Passing an empty string, i.e., "--rfc=", is the same as "--no-rfc" to override an option given earlier on the same command line. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t4014-format-patch.sh21
1 files changed, 19 insertions, 2 deletions
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index e37a1411ee..645c4189f9 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1368,13 +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 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 &&
+ 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' '