@@ -1662,13 +1662,19 @@ static void print_bases(struct base_tree_info *bases, FILE *file)
16621662 oidclr (& bases -> base_commit );
16631663}
16641664
1665- static const char * diff_title (struct strbuf * sb , int reroll_count ,
1666- const char * generic , const char * rerolled )
1665+ static const char * diff_title (struct strbuf * sb ,
1666+ const char * reroll_count ,
1667+ const char * generic ,
1668+ const char * rerolled )
16671669{
1668- if (reroll_count <= 0 )
1670+ int v ;
1671+
1672+ /* RFC may be v0, so allow -v1 to diff against v0 */
1673+ if (reroll_count && !strtol_i (reroll_count , 10 , & v ) &&
1674+ v >= 1 )
1675+ strbuf_addf (sb , rerolled , v - 1 );
1676+ else
16691677 strbuf_addstr (sb , generic );
1670- else /* RFC may be v0, so allow -v1 to diff against v0 */
1671- strbuf_addf (sb , rerolled , reroll_count - 1 );
16721678 return sb -> buf ;
16731679}
16741680
@@ -1717,7 +1723,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
17171723 struct strbuf buf = STRBUF_INIT ;
17181724 int use_patch_format = 0 ;
17191725 int quiet = 0 ;
1720- int reroll_count = -1 ;
1726+ const char * reroll_count = NULL ;
17211727 char * cover_from_description_arg = NULL ;
17221728 char * branch_name = NULL ;
17231729 char * base_commit = NULL ;
@@ -1751,7 +1757,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
17511757 N_ ("use <sfx> instead of '.patch'" )),
17521758 OPT_INTEGER (0 , "start-number" , & start_number ,
17531759 N_ ("start numbering patches at <n> instead of 1" )),
1754- OPT_INTEGER ('v' , "reroll-count" , & reroll_count ,
1760+ OPT_STRING ('v' , "reroll-count" , & reroll_count , N_ ( "reroll-count" ) ,
17551761 N_ ("mark the series as Nth re-roll" )),
17561762 OPT_INTEGER (0 , "filename-max-length" , & fmt_patch_name_max ,
17571763 N_ ("max length of output filename" )),
@@ -1862,9 +1868,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
18621868 if (cover_from_description_arg )
18631869 cover_from_description_mode = parse_cover_from_description (cover_from_description_arg );
18641870
1865- if (0 < reroll_count ) {
1871+ if (reroll_count ) {
18661872 struct strbuf sprefix = STRBUF_INIT ;
1867- strbuf_addf (& sprefix , "%s v%d" ,
1873+
1874+ strbuf_addf (& sprefix , "%s v%s" ,
18681875 rev .subject_prefix , reroll_count );
18691876 rev .reroll_count = reroll_count ;
18701877 rev .subject_prefix = strbuf_detach (& sprefix , NULL );
0 commit comments