@@ -1253,7 +1253,15 @@ static void show_diffstat(struct rev_info *rev,
1253
1253
fprintf (rev -> diffopt .file , "\n" );
1254
1254
}
1255
1255
1256
+ static void read_desc_file (struct strbuf * buf , const char * desc_file )
1257
+ {
1258
+ if (strbuf_read_file (buf , desc_file , 0 ) < 0 )
1259
+ die_errno (_ ("unable to read branch description file '%s'" ),
1260
+ desc_file );
1261
+ }
1262
+
1256
1263
static void prepare_cover_text (struct pretty_print_context * pp ,
1264
+ const char * description_file ,
1257
1265
const char * branch_name ,
1258
1266
struct strbuf * sb ,
1259
1267
const char * encoding ,
@@ -1267,7 +1275,9 @@ static void prepare_cover_text(struct pretty_print_context *pp,
1267
1275
if (cover_from_description_mode == COVER_FROM_NONE )
1268
1276
goto do_pp ;
1269
1277
1270
- if (branch_name && * branch_name )
1278
+ if (description_file && * description_file )
1279
+ read_desc_file (& description_sb , description_file );
1280
+ else if (branch_name && * branch_name )
1271
1281
read_branch_desc (& description_sb , branch_name );
1272
1282
if (!description_sb .len )
1273
1283
goto do_pp ;
@@ -1313,6 +1323,7 @@ static void get_notes_args(struct strvec *arg, struct rev_info *rev)
1313
1323
static void make_cover_letter (struct rev_info * rev , int use_separate_file ,
1314
1324
struct commit * origin ,
1315
1325
int nr , struct commit * * list ,
1326
+ const char * description_file ,
1316
1327
const char * branch_name ,
1317
1328
int quiet )
1318
1329
{
@@ -1352,7 +1363,8 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
1352
1363
pp .rev = rev ;
1353
1364
pp .print_email_subject = 1 ;
1354
1365
pp_user_info (& pp , NULL , & sb , committer , encoding );
1355
- prepare_cover_text (& pp , branch_name , & sb , encoding , need_8bit_cte );
1366
+ prepare_cover_text (& pp , description_file , branch_name , & sb ,
1367
+ encoding , need_8bit_cte );
1356
1368
fprintf (rev -> diffopt .file , "%s\n" , sb .buf );
1357
1369
1358
1370
strbuf_release (& sb );
@@ -1893,6 +1905,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1893
1905
int quiet = 0 ;
1894
1906
const char * reroll_count = NULL ;
1895
1907
char * cover_from_description_arg = NULL ;
1908
+ char * description_file = NULL ;
1896
1909
char * branch_name = NULL ;
1897
1910
char * base_commit = NULL ;
1898
1911
struct base_tree_info bases ;
@@ -1936,6 +1949,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1936
1949
OPT_STRING (0 , "cover-from-description" , & cover_from_description_arg ,
1937
1950
N_ ("cover-from-description-mode" ),
1938
1951
N_ ("generate parts of a cover letter based on a branch's description" )),
1952
+ OPT_FILENAME (0 , "description-file" , & description_file ,
1953
+ N_ ("use branch description from file" )),
1939
1954
OPT_CALLBACK_F (0 , "subject-prefix" , & rev , N_ ("prefix" ),
1940
1955
N_ ("use [<prefix>] instead of [PATCH]" ),
1941
1956
PARSE_OPT_NONEG , subject_prefix_callback ),
@@ -2321,7 +2336,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
2321
2336
if (thread )
2322
2337
gen_message_id (& rev , "cover" );
2323
2338
make_cover_letter (& rev , !!output_directory ,
2324
- origin , nr , list , branch_name , quiet );
2339
+ origin , nr , list , description_file , branch_name , quiet );
2325
2340
print_bases (& bases , rev .diffopt .file );
2326
2341
print_signature (rev .diffopt .file );
2327
2342
total ++ ;
0 commit comments