@@ -678,7 +678,7 @@ static int reopen_stdout(struct commit *commit, const char *subject,
678678 struct rev_info * rev , int quiet )
679679{
680680 struct strbuf filename = STRBUF_INIT ;
681- int suffix_len = strlen (fmt_patch_suffix ) + 1 ;
681+ int suffix_len = strlen (rev -> patch_suffix ) + 1 ;
682682
683683 if (output_directory ) {
684684 strbuf_addstr (& filename , output_directory );
@@ -689,7 +689,12 @@ static int reopen_stdout(struct commit *commit, const char *subject,
689689 strbuf_addch (& filename , '/' );
690690 }
691691
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 );
693698
694699 if (!quiet )
695700 fprintf (realstdout , "%s\n" , filename .buf + outdir_offset );
@@ -773,7 +778,6 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)
773778}
774779
775780static void make_cover_letter (struct rev_info * rev , int use_stdout ,
776- int numbered , int numbered_files ,
777781 struct commit * origin ,
778782 int nr , struct commit * * list , struct commit * head ,
779783 const char * branch_name ,
@@ -796,7 +800,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
796800 committer = git_committer_info (0 );
797801
798802 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 ))
800804 return ;
801805
802806 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)
10601064 int nr = 0 , total , i ;
10611065 int use_stdout = 0 ;
10621066 int start_number = -1 ;
1063- int numbered_files = 0 ; /* _just_ numbers */
1067+ int just_numbers = 0 ;
10641068 int ignore_if_in_upstream = 0 ;
10651069 int cover_letter = 0 ;
10661070 int boundary_count = 0 ;
@@ -1072,6 +1076,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
10721076 struct strbuf buf = STRBUF_INIT ;
10731077 int use_patch_format = 0 ;
10741078 int quiet = 0 ;
1079+ int reroll_count = -1 ;
10751080 char * branch_name = NULL ;
10761081 const struct option builtin_format_patch_options [] = {
10771082 { OPTION_CALLBACK , 'n' , "numbered" , & numbered , NULL ,
@@ -1085,12 +1090,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
10851090 N_ ("print patches to standard out" )),
10861091 OPT_BOOLEAN (0 , "cover-letter" , & cover_letter ,
10871092 N_ ("generate a cover letter" )),
1088- OPT_BOOLEAN (0 , "numbered-files" , & numbered_files ,
1093+ OPT_BOOLEAN (0 , "numbered-files" , & just_numbers ,
10891094 N_ ("use simple number sequence for output file names" )),
10901095 OPT_STRING (0 , "suffix" , & fmt_patch_suffix , N_ ("sfx" ),
10911096 N_ ("use <sfx> instead of '.patch'" )),
10921097 OPT_INTEGER (0 , "start-number" , & start_number ,
10931098 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" )),
10941101 { OPTION_CALLBACK , 0 , "subject-prefix" , & rev , N_ ("prefix" ),
10951102 N_ ("Use [<prefix>] instead of [PATCH]" ),
10961103 PARSE_OPT_NONEG , subject_prefix_callback },
@@ -1164,6 +1171,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
11641171 PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
11651172 PARSE_OPT_KEEP_DASHDASH );
11661173
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+
11671182 if (do_signoff ) {
11681183 const char * committer ;
11691184 const char * endpos ;
@@ -1354,12 +1369,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
13541369 const char * msgid = clean_message_id (in_reply_to );
13551370 string_list_append (rev .ref_message_ids , msgid );
13561371 }
1357- rev .numbered_files = numbered_files ;
1372+ rev .numbered_files = just_numbers ;
13581373 rev .patch_suffix = fmt_patch_suffix ;
13591374 if (cover_letter ) {
13601375 if (thread )
13611376 gen_message_id (& rev , "cover" );
1362- make_cover_letter (& rev , use_stdout , numbered , numbered_files ,
1377+ make_cover_letter (& rev , use_stdout ,
13631378 origin , nr , list , head , branch_name , quiet );
13641379 total ++ ;
13651380 start_number -- ;
@@ -1406,7 +1421,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
14061421 }
14071422
14081423 if (!use_stdout &&
1409- reopen_stdout (numbered_files ? NULL : commit , NULL , & rev , quiet ))
1424+ reopen_stdout (rev . numbered_files ? NULL : commit , NULL , & rev , quiet ))
14101425 die (_ ("Failed to create output files" ));
14111426 shown = log_tree_commit (& rev , commit );
14121427 free (commit -> buffer );
0 commit comments