Skip to content

Commit

Permalink
Merge branch 'ds/format-patch-rfc-and-k' into maint-2.45
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gitster committed Jul 2, 2024
2 parents 09e5e7f + cadcf58 commit f13710e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion builtin/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -2050,8 +2050,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (cover_from_description_arg)
cover_from_description_mode = parse_cover_from_description(cover_from_description_arg);

if (rfc)
if (rfc) {
strbuf_insertstr(&sprefix, 0, "RFC ");
subject_prefix = 1;
}

if (reroll_count) {
strbuf_addf(&sprefix, " v%s", reroll_count);
Expand Down
21 changes: 21 additions & 0 deletions t/t4014-format-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,27 @@ test_expect_success '--rfc is argument order independent' '
test_cmp expect actual
'

test_expect_success '--subject-prefix="<non-empty>" and -k cannot be used together' '
echo "fatal: options '\''--subject-prefix/--rfc'\'' and '\''-k'\'' cannot be used together" >expect.err &&
test_must_fail git format-patch -1 --stdout --subject-prefix="MYPREFIX" -k >actual.out 2>actual.err &&
test_must_be_empty actual.out &&
test_cmp expect.err actual.err
'

test_expect_success '--subject-prefix="" and -k cannot be used together' '
echo "fatal: options '\''--subject-prefix/--rfc'\'' and '\''-k'\'' cannot be used together" >expect.err &&
test_must_fail git format-patch -1 --stdout --subject-prefix="" -k >actual.out 2>actual.err &&
test_must_be_empty actual.out &&
test_cmp expect.err actual.err
'

test_expect_success '--rfc and -k cannot be used together' '
echo "fatal: options '\''--subject-prefix/--rfc'\'' and '\''-k'\'' cannot be used together" >expect.err &&
test_must_fail git format-patch -1 --stdout --rfc -k >actual.out 2>actual.err &&
test_must_be_empty actual.out &&
test_cmp expect.err actual.err
'

test_expect_success '--from=ident notices bogus ident' '
test_must_fail git format-patch -1 --stdout --from=foo >patch
'
Expand Down

0 comments on commit f13710e

Please sign in to comment.