1468
static int subject_prefix_callback(const struct option *opt, const char *arg,
1469
int unset)
1470
{
1471
+ struct strbuf *sprefix;
1472
+
1473
BUG_ON_OPT_NEG(unset);
1474
+ sprefix = opt->value;
1475
subject_prefix = 1;
1473
- ((struct rev_info *)opt->value)->subject_prefix = arg;
1476
+ strbuf_reset(sprefix);
1477
+ strbuf_addstr(sprefix, arg);
1478
return 0;
1479
}
1480
1477
-static int rfc_callback(const struct option *opt, const char *arg, int unset)
1478
-{
1479
- BUG_ON_OPT_NEG(unset);
1480
- BUG_ON_OPT_ARG(arg);
1481
- return subject_prefix_callback(opt, "RFC PATCH", unset);
1482
-}
1483
-
1481
static int numbered_cmdline_opt = 0;
1482
1483
static int numbered_callback(const struct option *opt, const char *arg,
1904
struct strbuf rdiff_title = STRBUF_INIT;
1905
struct strbuf sprefix = STRBUF_INIT;
1906
int creation_factor = -1;
1907
+ int rfc = 0;
1908
1909
const struct option builtin_format_patch_options[] = {
1910
OPT_CALLBACK_F('n', "numbered", &numbered, NULL,
1928
N_("mark the series as Nth re-roll")),
1929
OPT_INTEGER(0, "filename-max-length", &fmt_patch_name_max,
1930
N_("max length of output filename")),
1933
- OPT_CALLBACK_F(0, "rfc", &rev, NULL,
1934
- N_("use [RFC PATCH] instead of [PATCH]"),
1935
- PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback),
1931
+ OPT_BOOL(0, "rfc", &rfc, N_("use [RFC PATCH] instead of [PATCH]")),
1932
OPT_STRING(0, "cover-from-description", &cover_from_description_arg,
1933
N_("cover-from-description-mode"),
1934
N_("generate parts of a cover letter based on a branch's description")),
1939
- OPT_CALLBACK_F(0, "subject-prefix", &rev, N_("prefix"),
1935
+ OPT_CALLBACK_F(0, "subject-prefix", &sprefix, N_("prefix"),
1936
N_("use [<prefix>] instead of [PATCH]"),
1937
PARSE_OPT_NONEG, subject_prefix_callback),
1938
OPT_CALLBACK_F('o', "output-directory", &output_directory,
2012
rev.max_parents = 1;
2013
rev.diffopt.flags.recursive = 1;
2014
rev.diffopt.no_free = 1;
2019
- rev.subject_prefix = fmt_patch_subject_prefix;
2015
memset(&s_r_opt, 0, sizeof(s_r_opt));
2016
s_r_opt.def = "HEAD";
2017
s_r_opt.revarg_opt = REVARG_COMMITTISH;
2018
2019
+ strbuf_addstr(&sprefix, fmt_patch_subject_prefix);
2020
if (format_no_prefix)
2021
diff_set_noprefix(&rev.diffopt);
2022
2044
if (cover_from_description_arg)
2045
cover_from_description_mode = parse_cover_from_description(cover_from_description_arg);
2046
2047
+ if (rfc)
2048
+ strbuf_insertstr(&sprefix, 0, "RFC ");
2049
+
2050
if (reroll_count) {
2052
- strbuf_addf(&sprefix, "%s v%s",
2053
- rev.subject_prefix, reroll_count);
2051
+ strbuf_addf(&sprefix, " v%s", reroll_count);
2052
rev.reroll_count = reroll_count;
2055
- rev.subject_prefix = sprefix.buf;
2053
}
2054
2055
+ rev.subject_prefix = sprefix.buf;
2056
+
2057
for (i = 0; i < extra_hdr.nr; i++) {
2058
strbuf_addstr(&buf, extra_hdr.items[i].string);
2059
strbuf_addch(&buf, '\n');