Merge branch 'dd/format-patch-rfc-updates' into next
"git format-patch --rfc --subject-prefix=<foo>" used to ignore the "--subject-prefix" option and used "[RFC PATCH]"; now we will add "RFC" prefix to whatever subject prefix is specified. This is a backward compatible change that may deserve a note. * dd/format-patch-rfc-updates: format-patch: --rfc honors what --subject-prefix sets
This commit is contained in:
@ -221,9 +221,15 @@ populated with placeholder text.
|
|||||||
|
|
||||||
--subject-prefix=<subject prefix>::
|
--subject-prefix=<subject prefix>::
|
||||||
Instead of the standard '[PATCH]' prefix in the subject
|
Instead of the standard '[PATCH]' prefix in the subject
|
||||||
line, instead use '[<subject prefix>]'. This
|
line, instead use '[<subject prefix>]'. This can be used
|
||||||
allows for useful naming of a patch series, and can be
|
to name a patch series, and can be combined with the
|
||||||
combined with the `--numbered` option.
|
`--numbered` option.
|
||||||
|
+
|
||||||
|
The configuration variable `format.subjectPrefix` may also be used
|
||||||
|
to configure a subject prefix to apply to a given repository for
|
||||||
|
all patches. This is often useful on mailing lists which receive
|
||||||
|
patches for several repositories and can be used to disambiguate
|
||||||
|
the patches (with a value of e.g. "PATCH my-project").
|
||||||
|
|
||||||
--filename-max-length=<n>::
|
--filename-max-length=<n>::
|
||||||
Instead of the standard 64 bytes, chomp the generated output
|
Instead of the standard 64 bytes, chomp the generated output
|
||||||
@ -233,9 +239,9 @@ populated with placeholder text.
|
|||||||
variable, or 64 if unconfigured.
|
variable, or 64 if unconfigured.
|
||||||
|
|
||||||
--rfc::
|
--rfc::
|
||||||
Alias for `--subject-prefix="RFC PATCH"`. RFC means "Request For
|
Prepends "RFC" to the subject prefix (producing "RFC PATCH" by
|
||||||
Comments"; use this when sending an experimental patch for
|
default). RFC means "Request For Comments"; use this when sending
|
||||||
discussion rather than application.
|
an experimental patch for discussion rather than application.
|
||||||
|
|
||||||
-v <n>::
|
-v <n>::
|
||||||
--reroll-count=<n>::
|
--reroll-count=<n>::
|
||||||
|
@ -1480,17 +1480,14 @@ static int subject_prefix = 0;
|
|||||||
static int subject_prefix_callback(const struct option *opt, const char *arg,
|
static int subject_prefix_callback(const struct option *opt, const char *arg,
|
||||||
int unset)
|
int unset)
|
||||||
{
|
{
|
||||||
BUG_ON_OPT_NEG(unset);
|
struct strbuf *sprefix;
|
||||||
subject_prefix = 1;
|
|
||||||
((struct rev_info *)opt->value)->subject_prefix = arg;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int rfc_callback(const struct option *opt, const char *arg, int unset)
|
|
||||||
{
|
|
||||||
BUG_ON_OPT_NEG(unset);
|
BUG_ON_OPT_NEG(unset);
|
||||||
BUG_ON_OPT_ARG(arg);
|
sprefix = opt->value;
|
||||||
return subject_prefix_callback(opt, "RFC PATCH", unset);
|
subject_prefix = 1;
|
||||||
|
strbuf_reset(sprefix);
|
||||||
|
strbuf_addstr(sprefix, arg);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int numbered_cmdline_opt = 0;
|
static int numbered_cmdline_opt = 0;
|
||||||
@ -1920,6 +1917,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
|||||||
struct strbuf rdiff_title = STRBUF_INIT;
|
struct strbuf rdiff_title = STRBUF_INIT;
|
||||||
struct strbuf sprefix = STRBUF_INIT;
|
struct strbuf sprefix = STRBUF_INIT;
|
||||||
int creation_factor = -1;
|
int creation_factor = -1;
|
||||||
|
int rfc = 0;
|
||||||
|
|
||||||
const struct option builtin_format_patch_options[] = {
|
const struct option builtin_format_patch_options[] = {
|
||||||
OPT_CALLBACK_F('n', "numbered", &numbered, NULL,
|
OPT_CALLBACK_F('n', "numbered", &numbered, NULL,
|
||||||
@ -1943,15 +1941,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
|||||||
N_("mark the series as Nth re-roll")),
|
N_("mark the series as Nth re-roll")),
|
||||||
OPT_INTEGER(0, "filename-max-length", &fmt_patch_name_max,
|
OPT_INTEGER(0, "filename-max-length", &fmt_patch_name_max,
|
||||||
N_("max length of output filename")),
|
N_("max length of output filename")),
|
||||||
OPT_CALLBACK_F(0, "rfc", &rev, NULL,
|
OPT_BOOL(0, "rfc", &rfc, N_("use [RFC PATCH] instead of [PATCH]")),
|
||||||
N_("use [RFC PATCH] instead of [PATCH]"),
|
|
||||||
PARSE_OPT_NOARG | PARSE_OPT_NONEG, rfc_callback),
|
|
||||||
OPT_STRING(0, "cover-from-description", &cover_from_description_arg,
|
OPT_STRING(0, "cover-from-description", &cover_from_description_arg,
|
||||||
N_("cover-from-description-mode"),
|
N_("cover-from-description-mode"),
|
||||||
N_("generate parts of a cover letter based on a branch's description")),
|
N_("generate parts of a cover letter based on a branch's description")),
|
||||||
OPT_FILENAME(0, "description-file", &description_file,
|
OPT_FILENAME(0, "description-file", &description_file,
|
||||||
N_("use branch description from file")),
|
N_("use branch description from file")),
|
||||||
OPT_CALLBACK_F(0, "subject-prefix", &rev, N_("prefix"),
|
OPT_CALLBACK_F(0, "subject-prefix", &sprefix, N_("prefix"),
|
||||||
N_("use [<prefix>] instead of [PATCH]"),
|
N_("use [<prefix>] instead of [PATCH]"),
|
||||||
PARSE_OPT_NONEG, subject_prefix_callback),
|
PARSE_OPT_NONEG, subject_prefix_callback),
|
||||||
OPT_CALLBACK_F('o', "output-directory", &output_directory,
|
OPT_CALLBACK_F('o', "output-directory", &output_directory,
|
||||||
@ -2031,11 +2027,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
|||||||
rev.max_parents = 1;
|
rev.max_parents = 1;
|
||||||
rev.diffopt.flags.recursive = 1;
|
rev.diffopt.flags.recursive = 1;
|
||||||
rev.diffopt.no_free = 1;
|
rev.diffopt.no_free = 1;
|
||||||
rev.subject_prefix = fmt_patch_subject_prefix;
|
|
||||||
memset(&s_r_opt, 0, sizeof(s_r_opt));
|
memset(&s_r_opt, 0, sizeof(s_r_opt));
|
||||||
s_r_opt.def = "HEAD";
|
s_r_opt.def = "HEAD";
|
||||||
s_r_opt.revarg_opt = REVARG_COMMITTISH;
|
s_r_opt.revarg_opt = REVARG_COMMITTISH;
|
||||||
|
|
||||||
|
strbuf_addstr(&sprefix, fmt_patch_subject_prefix);
|
||||||
if (format_no_prefix)
|
if (format_no_prefix)
|
||||||
diff_set_noprefix(&rev.diffopt);
|
diff_set_noprefix(&rev.diffopt);
|
||||||
|
|
||||||
@ -2063,13 +2059,16 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
|||||||
if (cover_from_description_arg)
|
if (cover_from_description_arg)
|
||||||
cover_from_description_mode = parse_cover_from_description(cover_from_description_arg);
|
cover_from_description_mode = parse_cover_from_description(cover_from_description_arg);
|
||||||
|
|
||||||
|
if (rfc)
|
||||||
|
strbuf_insertstr(&sprefix, 0, "RFC ");
|
||||||
|
|
||||||
if (reroll_count) {
|
if (reroll_count) {
|
||||||
strbuf_addf(&sprefix, "%s v%s",
|
strbuf_addf(&sprefix, " v%s", reroll_count);
|
||||||
rev.subject_prefix, reroll_count);
|
|
||||||
rev.reroll_count = reroll_count;
|
rev.reroll_count = reroll_count;
|
||||||
rev.subject_prefix = sprefix.buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rev.subject_prefix = sprefix.buf;
|
||||||
|
|
||||||
for (i = 0; i < extra_hdr.nr; i++) {
|
for (i = 0; i < extra_hdr.nr; i++) {
|
||||||
strbuf_addstr(&buf, extra_hdr.items[i].string);
|
strbuf_addstr(&buf, extra_hdr.items[i].string);
|
||||||
strbuf_addch(&buf, '\n');
|
strbuf_addch(&buf, '\n');
|
||||||
|
@ -1373,7 +1373,27 @@ test_expect_success '--rfc' '
|
|||||||
Subject: [RFC PATCH 1/1] header with . in it
|
Subject: [RFC PATCH 1/1] header with . in it
|
||||||
EOF
|
EOF
|
||||||
git format-patch -n -1 --stdout --rfc >patch &&
|
git format-patch -n -1 --stdout --rfc >patch &&
|
||||||
grep ^Subject: patch >actual &&
|
grep "^Subject:" patch >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success '--rfc does not overwrite prefix' '
|
||||||
|
cat >expect <<-\EOF &&
|
||||||
|
Subject: [RFC PATCH foobar 1/1] header with . in it
|
||||||
|
EOF
|
||||||
|
git -c format.subjectPrefix="PATCH foobar" \
|
||||||
|
format-patch -n -1 --stdout --rfc >patch &&
|
||||||
|
grep "^Subject:" patch >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success '--rfc is argument order independent' '
|
||||||
|
cat >expect <<-\EOF &&
|
||||||
|
Subject: [RFC PATCH foobar 1/1] header with . in it
|
||||||
|
EOF
|
||||||
|
git format-patch -n -1 --stdout --rfc \
|
||||||
|
--subject-prefix="PATCH foobar" >patch &&
|
||||||
|
grep "^Subject:" patch >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user