@@ -1480,19 +1480,16 @@ static int subject_prefix = 0;
1480
1480
static int subject_prefix_callback (const struct option * opt , const char * arg ,
1481
1481
int unset )
1482
1482
{
1483
+ struct strbuf * sprefix ;
1484
+
1483
1485
BUG_ON_OPT_NEG (unset );
1486
+ sprefix = opt -> value ;
1484
1487
subject_prefix = 1 ;
1485
- ((struct rev_info * )opt -> value )-> subject_prefix = arg ;
1488
+ strbuf_reset (sprefix );
1489
+ strbuf_addstr (sprefix , arg );
1486
1490
return 0 ;
1487
1491
}
1488
1492
1489
- static int rfc_callback (const struct option * opt , const char * arg , int unset )
1490
- {
1491
- BUG_ON_OPT_NEG (unset );
1492
- BUG_ON_OPT_ARG (arg );
1493
- return subject_prefix_callback (opt , "RFC PATCH" , unset );
1494
- }
1495
-
1496
1493
static int numbered_cmdline_opt = 0 ;
1497
1494
1498
1495
static int numbered_callback (const struct option * opt , const char * arg ,
@@ -1920,6 +1917,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1920
1917
struct strbuf rdiff_title = STRBUF_INIT ;
1921
1918
struct strbuf sprefix = STRBUF_INIT ;
1922
1919
int creation_factor = -1 ;
1920
+ int rfc = 0 ;
1923
1921
1924
1922
const struct option builtin_format_patch_options [] = {
1925
1923
OPT_CALLBACK_F ('n' , "numbered" , & numbered , NULL ,
@@ -1943,15 +1941,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1943
1941
N_ ("mark the series as Nth re-roll" )),
1944
1942
OPT_INTEGER (0 , "filename-max-length" , & fmt_patch_name_max ,
1945
1943
N_ ("max length of output filename" )),
1946
- OPT_CALLBACK_F (0 , "rfc" , & rev , NULL ,
1947
- N_ ("use [RFC PATCH] instead of [PATCH]" ),
1948
- PARSE_OPT_NOARG | PARSE_OPT_NONEG , rfc_callback ),
1944
+ OPT_BOOL (0 , "rfc" , & rfc , N_ ("use [RFC PATCH] instead of [PATCH]" )),
1949
1945
OPT_STRING (0 , "cover-from-description" , & cover_from_description_arg ,
1950
1946
N_ ("cover-from-description-mode" ),
1951
1947
N_ ("generate parts of a cover letter based on a branch's description" )),
1952
1948
OPT_FILENAME (0 , "description-file" , & description_file ,
1953
1949
N_ ("use branch description from file" )),
1954
- OPT_CALLBACK_F (0 , "subject-prefix" , & rev , N_ ("prefix" ),
1950
+ OPT_CALLBACK_F (0 , "subject-prefix" , & sprefix , N_ ("prefix" ),
1955
1951
N_ ("use [<prefix>] instead of [PATCH]" ),
1956
1952
PARSE_OPT_NONEG , subject_prefix_callback ),
1957
1953
OPT_CALLBACK_F ('o' , "output-directory" , & output_directory ,
@@ -2031,11 +2027,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
2031
2027
rev .max_parents = 1 ;
2032
2028
rev .diffopt .flags .recursive = 1 ;
2033
2029
rev .diffopt .no_free = 1 ;
2034
- rev .subject_prefix = fmt_patch_subject_prefix ;
2035
2030
memset (& s_r_opt , 0 , sizeof (s_r_opt ));
2036
2031
s_r_opt .def = "HEAD" ;
2037
2032
s_r_opt .revarg_opt = REVARG_COMMITTISH ;
2038
2033
2034
+ strbuf_addstr (& sprefix , fmt_patch_subject_prefix );
2039
2035
if (format_no_prefix )
2040
2036
diff_set_noprefix (& rev .diffopt );
2041
2037
@@ -2063,13 +2059,16 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
2063
2059
if (cover_from_description_arg )
2064
2060
cover_from_description_mode = parse_cover_from_description (cover_from_description_arg );
2065
2061
2062
+ if (rfc )
2063
+ strbuf_insertstr (& sprefix , 0 , "RFC " );
2064
+
2066
2065
if (reroll_count ) {
2067
- strbuf_addf (& sprefix , "%s v%s" ,
2068
- rev .subject_prefix , reroll_count );
2066
+ strbuf_addf (& sprefix , " v%s" , reroll_count );
2069
2067
rev .reroll_count = reroll_count ;
2070
- rev .subject_prefix = sprefix .buf ;
2071
2068
}
2072
2069
2070
+ rev .subject_prefix = sprefix .buf ;
2071
+
2073
2072
for (i = 0 ; i < extra_hdr .nr ; i ++ ) {
2074
2073
strbuf_addstr (& buf , extra_hdr .items [i ].string );
2075
2074
strbuf_addch (& buf , '\n' );
0 commit comments