Skip to content

Commit ce36894

Browse files
committed
format-patch: "--rfc=-(WIP)" appends to produce [PATCH (WIP)]
In the previous step, the "--rfc" option of "format-patch" learned to take an optional string value to prepend to the subject prefix, so that --rfc=WIP can give "[WIP PATCH]". There may be cases in which the extra string wants to come after the subject prefix. Extend the mechanism to allow "--rfc=-(WIP)" [*] to signal that the extra string is to be appended instead of getting prepended, resulting in "[PATCH (WIP)]". In the documentation, discourage (ab)using "--rfc=-RFC" to say "[PATCH RFC]" just to be different, when "[RFC PATCH]" is the norm. [Footnote] * The syntax takes inspiration from Perl's open syntax that opens pipes "open fh, '|-', 'cmd'", where the dash signals "the other stuff comes here". Signed-off-by: Junio C Hamano <[email protected]>
1 parent ce48fb2 commit ce36894

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

Documentation/git-format-patch.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ RFC means "Request For Comments"; use this when sending
247247
an experimental patch for discussion rather than application.
248248
"--rfc=WIP" may also be a useful way to indicate that a patch
249249
is not complete yet ("WIP" stands for "Work In Progress").
250+
+
251+
If the convention of the receiving community for a particular extra
252+
string is to have it _after_ the subject prefix, the string _<rfc>_
253+
can be prefixed with a dash ("`-`") to signal that the the rest of
254+
the _<rfc>_ string should be appended to the subject prefix instead,
255+
e.g., `--rfc='-(WIP)'` results in "PATCH (WIP)".
250256

251257
-v <n>::
252258
--reroll-count=<n>::

builtin/log.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,8 +2065,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
20652065
if (cover_from_description_arg)
20662066
cover_from_description_mode = parse_cover_from_description(cover_from_description_arg);
20672067

2068-
if (rfc && rfc[0])
2069-
strbuf_insertf(&sprefix, 0, "%s ", rfc);
2068+
if (rfc && rfc[0]) {
2069+
if (rfc[0] == '-')
2070+
strbuf_addf(&sprefix, " %s", rfc + 1);
2071+
else
2072+
strbuf_insertf(&sprefix, 0, "%s ", rfc);
2073+
}
20702074

20712075
if (reroll_count) {
20722076
strbuf_addf(&sprefix, " v%s", reroll_count);

t/t4014-format-patch.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,15 @@ test_expect_success '--rfc=WIP and --rfc=' '
13941394
test_cmp expect-raw actual
13951395
'
13961396

1397+
test_expect_success '--rfc=-(WIP) appends' '
1398+
cat >expect <<-\EOF &&
1399+
Subject: [PATCH (WIP) 1/1] header with . in it
1400+
EOF
1401+
git format-patch -n -1 --stdout --rfc="-(WIP)" >patch &&
1402+
grep "^Subject:" patch >actual &&
1403+
test_cmp expect actual
1404+
'
1405+
13971406
test_expect_success '--rfc does not overwrite prefix' '
13981407
cat >expect <<-\EOF &&
13991408
Subject: [RFC PATCH foobar 1/1] header with . in it

0 commit comments

Comments
 (0)