1343
shortlog_output(log);
1344
}
1345
1346
+static void generate_commit_list_cover(FILE *cover_file, const char *format,
1347
+ struct commit **list, int n)
1348
+{
1349
+ struct strbuf commit_line = STRBUF_INIT;
1350
+ struct pretty_print_context ctx = {0};
1351
+ struct rev_info rev = REV_INFO_INIT;
1352
+
1353
+ strbuf_init(&commit_line, 0);
1354
+ rev.total = n;
1355
+ ctx.rev = &rev;
1356
+ for (int i = n - 1; i >= 0; i--) {
1357
+ rev.nr = n - i;
1358
+ repo_format_commit_message(the_repository, list[i], format,
1359
+ &commit_line, &ctx);
1360
+ fprintf(cover_file, "%s\n", commit_line.buf);
1361
+ strbuf_reset(&commit_line);
1362
+ }
1363
+ fprintf(cover_file, "\n");
1364
+
1365
+ strbuf_release(&commit_line);
1366
+}
1367
+
1368
static void make_cover_letter(struct rev_info *rev, int use_separate_file,
1369
struct commit *origin,
1370
int nr, struct commit **list,
1371
const char *description_file,
1372
const char *branch_name,
1373
int quiet,
1352
- const struct format_config *cfg)
1374
+ const struct format_config *cfg,
1375
+ const char *format)
1376
{
1377
const char *committer;
1378
struct shortlog log;
1419
free(pp.after_subject);
1420
strbuf_release(&sb);
1421
1399
- generate_shortlog_cover_letter(&log, rev, list, nr);
1422
+ if (skip_prefix(format, "log:", &format))
1423
+ generate_commit_list_cover(rev->diffopt.file, format, list, nr);
1424
+ else if (!strcmp(format, "shortlog"))
1425
+ generate_shortlog_cover_letter(&log, rev, list, nr);
1426
+ else
1427
+ die(_("'%s' is not a valid format string"), format);
1428
1429
/* We can only do diffstat with a unique reference point */
1430
if (origin)
1942
int just_numbers = 0;
1943
int ignore_if_in_upstream = 0;
1944
int cover_letter = -1;
1945
+ const char *cover_letter_fmt = NULL;
1946
int boundary_count = 0;
1947
int no_binary_diff = 0;
1948
int zero_commit = 0;
1989
N_("print patches to standard out")),
1990
OPT_BOOL(0, "cover-letter", &cover_letter,
1991
N_("generate a cover letter")),
1992
+ OPT_STRING(0, "cover-letter-format", &cover_letter_fmt, N_("format-spec"),
1993
+ N_("format spec used for the commit list in the cover letter")),
1994
OPT_BOOL(0, "numbered-files", &just_numbers,
1995
N_("use simple number sequence for output file names")),
1996
OPT_STRING(0, "suffix", &fmt_patch_suffix, N_("sfx"),
2328
/* nothing to do */
2329
goto done;
2330
total = list.nr;
2331
+
2332
if (cover_letter == -1) {
2333
if (cfg.config_cover_letter == COVER_AUTO)
2334
cover_letter = (total > 1);
2415
}
2416
rev.numbered_files = just_numbers;
2417
rev.patch_suffix = fmt_patch_suffix;
2418
+
2419
if (cover_letter) {
2420
if (cfg.thread)
2421
gen_message_id(&rev, "cover");
2422
make_cover_letter(&rev, !!output_directory,
2423
origin, list.nr, list.items,
2391
- description_file, branch_name, quiet, &cfg);
2424
+ description_file, branch_name, quiet, &cfg,
2425
+ cover_letter_fmt);
2426
print_bases(&bases, rev.diffopt.file);
2427
print_signature(signature, rev.diffopt.file);
2428
total++;