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>

Josh Triplett committed Sep 19, 2016 at 21:23 UTC 68e83a5b8277adfc6f8a307bc2454bc6723717f4
3 files changed +25 -2
Documentation/git-format-patch.txt
+7 -1
@@ -19,7 +19,8 @@ SYNOPSIS
19 [--start-number <n>] [--numbered-files]
20 [--in-reply-to=Message-Id] [--suffix=.<sfx>]
21 [--ignore-if-in-upstream]
22 - [--subject-prefix=Subject-Prefix] [(--reroll-count|-v) <n>]
22 + [--rfc] [--subject-prefix=Subject-Prefix]
23 + [(--reroll-count|-v) <n>]
24 [--to=<email>] [--cc=<email>]
25 [--[no-]cover-letter] [--quiet] [--notes[=<ref>]]
26 [<common diff options>]
@@ -172,6 +173,11 @@ will want to ensure that threading is disabled for `git send-email`.
173 allows for useful naming of a patch series, and can be
174 combined with the `--numbered` option.
175
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 +
181 -v <n>::
182 --reroll-count=<n>::
183 Mark the series as the <n>-th iteration of the topic. The
builtin/log.c
+9 -1
@@ -1112,6 +1112,11 @@ static int subject_prefix_callback(const struct option *opt, const char *arg,
1112 return 0;
1113 }
1114
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 +
1120 static int numbered_cmdline_opt = 0;
1121
1122 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)
1424 N_("start numbering patches at <n> instead of 1")),
1425 OPT_INTEGER('v', "reroll-count", &reroll_count,
1426 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 },
1430 { OPTION_CALLBACK, 0, "subject-prefix", &rev, N_("prefix"),
1431 N_("Use [<prefix>] instead of [PATCH]"),
1432 PARSE_OPT_NONEG, subject_prefix_callback },
@@ -1557,7 +1565,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1565 if (numbered && keep_subject)
1566 die (_("-n and -k are mutually exclusive."));
1567 if (keep_subject && subject_prefix)
1560 - die (_("--subject-prefix and -k are mutually exclusive."));
1568 + die (_("--subject-prefix/--rfc and -k are mutually exclusive."));
1569 rev.preserve_subject = keep_subject;
1570
1571 argc = setup_revisions(argc, argv, &rev, &s_r_opt);
t/t4014-format-patch.sh
+9
@@ -1073,6 +1073,15 @@ test_expect_success 'empty subject prefix does not have extra space' '
1073 test_cmp expect actual
1074 '
1075
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 +
1085 test_expect_success '--from=ident notices bogus ident' '
1086 test_must_fail git format-patch -1 --stdout --from=foo >patch
1087 '