@@ -678,7 +678,7 @@ static int reopen_stdout(struct commit *commit, const char *subject,
678
678
struct rev_info * rev , int quiet )
679
679
{
680
680
struct strbuf filename = STRBUF_INIT ;
681
- int suffix_len = strlen (fmt_patch_suffix ) + 1 ;
681
+ int suffix_len = strlen (rev -> patch_suffix ) + 1 ;
682
682
683
683
if (output_directory ) {
684
684
strbuf_addstr (& filename , output_directory );
@@ -689,7 +689,12 @@ static int reopen_stdout(struct commit *commit, const char *subject,
689
689
strbuf_addch (& filename , '/' );
690
690
}
691
691
692
- get_patch_filename (commit , subject , rev -> nr , fmt_patch_suffix , & filename );
692
+ if (rev -> numbered_files )
693
+ strbuf_addf (& filename , "%d" , rev -> nr );
694
+ else if (commit )
695
+ fmt_output_commit (& filename , commit , rev );
696
+ else
697
+ fmt_output_subject (& filename , subject , rev );
693
698
694
699
if (!quiet )
695
700
fprintf (realstdout , "%s\n" , filename .buf + outdir_offset );
@@ -773,7 +778,6 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)
773
778
}
774
779
775
780
static void make_cover_letter (struct rev_info * rev , int use_stdout ,
776
- int numbered , int numbered_files ,
777
781
struct commit * origin ,
778
782
int nr , struct commit * * list , struct commit * head ,
779
783
const char * branch_name ,
@@ -796,7 +800,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
796
800
committer = git_committer_info (0 );
797
801
798
802
if (!use_stdout &&
799
- reopen_stdout (NULL , numbered_files ? NULL : "cover-letter" , rev , quiet ))
803
+ reopen_stdout (NULL , rev -> numbered_files ? NULL : "cover-letter" , rev , quiet ))
800
804
return ;
801
805
802
806
log_write_email_headers (rev , head , & pp .subject , & pp .after_subject ,
@@ -1060,7 +1064,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1060
1064
int nr = 0 , total , i ;
1061
1065
int use_stdout = 0 ;
1062
1066
int start_number = -1 ;
1063
- int numbered_files = 0 ; /* _just_ numbers */
1067
+ int just_numbers = 0 ;
1064
1068
int ignore_if_in_upstream = 0 ;
1065
1069
int cover_letter = 0 ;
1066
1070
int boundary_count = 0 ;
@@ -1072,6 +1076,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1072
1076
struct strbuf buf = STRBUF_INIT ;
1073
1077
int use_patch_format = 0 ;
1074
1078
int quiet = 0 ;
1079
+ int reroll_count = -1 ;
1075
1080
char * branch_name = NULL ;
1076
1081
const struct option builtin_format_patch_options [] = {
1077
1082
{ OPTION_CALLBACK , 'n' , "numbered" , & numbered , NULL ,
@@ -1085,12 +1090,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1085
1090
N_ ("print patches to standard out" )),
1086
1091
OPT_BOOLEAN (0 , "cover-letter" , & cover_letter ,
1087
1092
N_ ("generate a cover letter" )),
1088
- OPT_BOOLEAN (0 , "numbered-files" , & numbered_files ,
1093
+ OPT_BOOLEAN (0 , "numbered-files" , & just_numbers ,
1089
1094
N_ ("use simple number sequence for output file names" )),
1090
1095
OPT_STRING (0 , "suffix" , & fmt_patch_suffix , N_ ("sfx" ),
1091
1096
N_ ("use <sfx> instead of '.patch'" )),
1092
1097
OPT_INTEGER (0 , "start-number" , & start_number ,
1093
1098
N_ ("start numbering patches at <n> instead of 1" )),
1099
+ OPT_INTEGER ('v' , "reroll-count" , & reroll_count ,
1100
+ N_ ("mark the series as Nth re-roll" )),
1094
1101
{ OPTION_CALLBACK , 0 , "subject-prefix" , & rev , N_ ("prefix" ),
1095
1102
N_ ("Use [<prefix>] instead of [PATCH]" ),
1096
1103
PARSE_OPT_NONEG , subject_prefix_callback },
@@ -1164,6 +1171,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1164
1171
PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
1165
1172
PARSE_OPT_KEEP_DASHDASH );
1166
1173
1174
+ if (0 < reroll_count ) {
1175
+ struct strbuf sprefix = STRBUF_INIT ;
1176
+ strbuf_addf (& sprefix , "%s v%d" ,
1177
+ rev .subject_prefix , reroll_count );
1178
+ rev .reroll_count = reroll_count ;
1179
+ rev .subject_prefix = strbuf_detach (& sprefix , NULL );
1180
+ }
1181
+
1167
1182
if (do_signoff ) {
1168
1183
const char * committer ;
1169
1184
const char * endpos ;
@@ -1354,12 +1369,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1354
1369
const char * msgid = clean_message_id (in_reply_to );
1355
1370
string_list_append (rev .ref_message_ids , msgid );
1356
1371
}
1357
- rev .numbered_files = numbered_files ;
1372
+ rev .numbered_files = just_numbers ;
1358
1373
rev .patch_suffix = fmt_patch_suffix ;
1359
1374
if (cover_letter ) {
1360
1375
if (thread )
1361
1376
gen_message_id (& rev , "cover" );
1362
- make_cover_letter (& rev , use_stdout , numbered , numbered_files ,
1377
+ make_cover_letter (& rev , use_stdout ,
1363
1378
origin , nr , list , head , branch_name , quiet );
1364
1379
total ++ ;
1365
1380
start_number -- ;
@@ -1406,7 +1421,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1406
1421
}
1407
1422
1408
1423
if (!use_stdout &&
1409
- reopen_stdout (numbered_files ? NULL : commit , NULL , & rev , quiet ))
1424
+ reopen_stdout (rev . numbered_files ? NULL : commit , NULL , & rev , quiet ))
1410
1425
die (_ ("Failed to create output files" ));
1411
1426
shown = log_tree_commit (& rev , commit );
1412
1427
free (commit -> buffer );
0 commit comments