Skip to content

Commit f13710e

Browse files
committed
Merge branch 'ds/format-patch-rfc-and-k' into maint-2.45
The "-k" and "--rfc" options of "format-patch" will now error out when used together, as one tells us not to add anything to the title of the commit, and the other one tells us to add "RFC" in addition to "PATCH". * ds/format-patch-rfc-and-k: format-patch: ensure that --rfc and -k are mutually exclusive
2 parents 09e5e7f + cadcf58 commit f13710e

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

builtin/log.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2050,8 +2050,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
20502050
if (cover_from_description_arg)
20512051
cover_from_description_mode = parse_cover_from_description(cover_from_description_arg);
20522052

2053-
if (rfc)
2053+
if (rfc) {
20542054
strbuf_insertstr(&sprefix, 0, "RFC ");
2055+
subject_prefix = 1;
2056+
}
20552057

20562058
if (reroll_count) {
20572059
strbuf_addf(&sprefix, " v%s", reroll_count);

t/t4014-format-patch.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,27 @@ test_expect_success '--rfc is argument order independent' '
13971397
test_cmp expect actual
13981398
'
13991399

1400+
test_expect_success '--subject-prefix="<non-empty>" and -k cannot be used together' '
1401+
echo "fatal: options '\''--subject-prefix/--rfc'\'' and '\''-k'\'' cannot be used together" >expect.err &&
1402+
test_must_fail git format-patch -1 --stdout --subject-prefix="MYPREFIX" -k >actual.out 2>actual.err &&
1403+
test_must_be_empty actual.out &&
1404+
test_cmp expect.err actual.err
1405+
'
1406+
1407+
test_expect_success '--subject-prefix="" and -k cannot be used together' '
1408+
echo "fatal: options '\''--subject-prefix/--rfc'\'' and '\''-k'\'' cannot be used together" >expect.err &&
1409+
test_must_fail git format-patch -1 --stdout --subject-prefix="" -k >actual.out 2>actual.err &&
1410+
test_must_be_empty actual.out &&
1411+
test_cmp expect.err actual.err
1412+
'
1413+
1414+
test_expect_success '--rfc and -k cannot be used together' '
1415+
echo "fatal: options '\''--subject-prefix/--rfc'\'' and '\''-k'\'' cannot be used together" >expect.err &&
1416+
test_must_fail git format-patch -1 --stdout --rfc -k >actual.out 2>actual.err &&
1417+
test_must_be_empty actual.out &&
1418+
test_cmp expect.err actual.err
1419+
'
1420+
14001421
test_expect_success '--from=ident notices bogus ident' '
14011422
test_must_fail git format-patch -1 --stdout --from=foo >patch
14021423
'

0 commit comments

Comments
 (0)