Skip to content

Commit 5fe10fe

Browse files
committed
format-patch: add --reroll-count=$N option
The --reroll-count=$N option, when given a positive integer: - Adds " v$N" to the subject prefix specified. As the default subject prefix string is "PATCH", --reroll-count=2 makes it "PATCH v2". - Prefixes "v$N-" to the names used for output files. The cover letter, whose name is usually 0000-cover-letter.patch, becomes v2-0000-cover-letter.patch when given --reroll-count=2. This allows users to use the same --output-directory for multiple iterations of the same series, without letting the output for a newer round overwrite output files from the earlier rounds. The user can incorporate materials from earlier rounds to update the newly minted iteration, and use "send-email v2-*.patch" to send out the patches belonging to the second iteration easily. Signed-off-by: Junio C Hamano <[email protected]>
1 parent d28b5d4 commit 5fe10fe

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

builtin/log.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
10611061
struct strbuf buf = STRBUF_INIT;
10621062
int use_patch_format = 0;
10631063
int quiet = 0;
1064+
int reroll_count = -1;
10641065
char *branch_name = NULL;
10651066
const struct option builtin_format_patch_options[] = {
10661067
{ OPTION_CALLBACK, 'n', "numbered", &numbered, NULL,
@@ -1080,6 +1081,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
10801081
N_("use <sfx> instead of '.patch'")),
10811082
OPT_INTEGER(0, "start-number", &start_number,
10821083
N_("start numbering patches at <n> instead of 1")),
1084+
OPT_INTEGER(0, "reroll-count", &reroll_count,
1085+
N_("mark the series as Nth re-roll")),
10831086
{ OPTION_CALLBACK, 0, "subject-prefix", &rev, N_("prefix"),
10841087
N_("Use [<prefix>] instead of [PATCH]"),
10851088
PARSE_OPT_NONEG, subject_prefix_callback },
@@ -1152,6 +1155,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
11521155
PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
11531156
PARSE_OPT_KEEP_DASHDASH);
11541157

1158+
if (0 < reroll_count) {
1159+
struct strbuf sprefix = STRBUF_INIT;
1160+
strbuf_addf(&sprefix, "%s v%d",
1161+
rev.subject_prefix, reroll_count);
1162+
rev.reroll_count = reroll_count;
1163+
rev.subject_prefix = strbuf_detach(&sprefix, NULL);
1164+
}
1165+
11551166
if (do_signoff) {
11561167
const char *committer;
11571168
const char *endpos;

log-tree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ void fmt_output_subject(struct strbuf *filename,
308308
int start_len = filename->len;
309309
int max_len = start_len + FORMAT_PATCH_NAME_MAX - (strlen(suffix) + 1);
310310

311+
if (0 < info->reroll_count)
312+
strbuf_addf(filename, "v%d-", info->reroll_count);
311313
strbuf_addf(filename, "%04d-%s", nr, subject);
312314

313315
if (max_len < filename->len)

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ struct rev_info {
134134
const char *mime_boundary;
135135
const char *patch_suffix;
136136
int numbered_files;
137+
int reroll_count;
137138
char *message_id;
138139
struct string_list *ref_message_ids;
139140
const char *add_signoff;

0 commit comments

Comments
 (0)