Skip to content

Commit 68e83a5

Browse files
joshtriplettgitster
authored andcommitted
format-patch: add "--rfc" for the common case of [RFC PATCH]
Add an alias for --subject-prefix='RFC PATCH', which is used commonly in some development communities to deserve such a short-hand. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6ebdac1 commit 68e83a5

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

Documentation/git-format-patch.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ SYNOPSIS
1919
[--start-number <n>] [--numbered-files]
2020
[--in-reply-to=Message-Id] [--suffix=.<sfx>]
2121
[--ignore-if-in-upstream]
22-
[--subject-prefix=Subject-Prefix] [(--reroll-count|-v) <n>]
22+
[--rfc] [--subject-prefix=Subject-Prefix]
23+
[(--reroll-count|-v) <n>]
2324
[--to=<email>] [--cc=<email>]
2425
[--[no-]cover-letter] [--quiet] [--notes[=<ref>]]
2526
[<common diff options>]
@@ -172,6 +173,11 @@ will want to ensure that threading is disabled for `git send-email`.
172173
allows for useful naming of a patch series, and can be
173174
combined with the `--numbered` option.
174175

176+
--rfc::
177+
Alias for `--subject-prefix="RFC PATCH"`. RFC means "Request For
178+
Comments"; use this when sending an experimental patch for
179+
discussion rather than application.
180+
175181
-v <n>::
176182
--reroll-count=<n>::
177183
Mark the series as the <n>-th iteration of the topic. The

builtin/log.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,11 @@ static int subject_prefix_callback(const struct option *opt, const char *arg,
11121112
return 0;
11131113
}
11141114

1115+
static int rfc_callback(const struct option *opt, const char *arg, int unset)
1116+
{
1117+
return subject_prefix_callback(opt, "RFC PATCH", unset);
1118+
}
1119+
11151120
static int numbered_cmdline_opt = 0;
11161121

11171122
static int numbered_callback(const struct option *opt, const char *arg,
@@ -1419,6 +1424,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
14191424
N_("start numbering patches at <n> instead of 1")),
14201425
OPT_INTEGER('v', "reroll-count", &reroll_count,
14211426
N_("mark the series as Nth re-roll")),
1427+
{ OPTION_CALLBACK, 0, "rfc", &rev, NULL,
1428+
N_("Use [RFC PATCH] instead of [PATCH]"),
1429+
PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback },
14221430
{ OPTION_CALLBACK, 0, "subject-prefix", &rev, N_("prefix"),
14231431
N_("Use [<prefix>] instead of [PATCH]"),
14241432
PARSE_OPT_NONEG, subject_prefix_callback },
@@ -1557,7 +1565,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
15571565
if (numbered && keep_subject)
15581566
die (_("-n and -k are mutually exclusive."));
15591567
if (keep_subject && subject_prefix)
1560-
die (_("--subject-prefix and -k are mutually exclusive."));
1568+
die (_("--subject-prefix/--rfc and -k are mutually exclusive."));
15611569
rev.preserve_subject = keep_subject;
15621570

15631571
argc = setup_revisions(argc, argv, &rev, &s_r_opt);

t/t4014-format-patch.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,15 @@ test_expect_success 'empty subject prefix does not have extra space' '
10731073
test_cmp expect actual
10741074
'
10751075

1076+
test_expect_success '--rfc' '
1077+
cat >expect <<-\EOF &&
1078+
Subject: [RFC PATCH 1/1] header with . in it
1079+
EOF
1080+
git format-patch -n -1 --stdout --rfc >patch &&
1081+
grep ^Subject: patch >actual &&
1082+
test_cmp expect actual
1083+
'
1084+
10761085
test_expect_success '--from=ident notices bogus ident' '
10771086
test_must_fail git format-patch -1 --stdout --from=foo >patch
10781087
'

0 commit comments

Comments
 (0)