Subject: Re: [PATCH v2 0/2] format-patch: add cover-letter-format option

From: Junio C Hamano <[email-masked]>
Date: Tue, 24 Feb 2026 13:39:48 -0800

Junio C Hamano <[email-masked]> writes:

> Mirko Faina <[email-masked]> writes:
>
>> From: Mroik <[email-masked]>
>>
>> I've dropped the first patch of the series and applied the changes that
>> Jeff suggested.
>
>
> These are queued somewhere in 'seen', with a small fix-up to have
> the build pass plus a bit of obvious tweak on error handling, but
> most of the remarks I made in my reviews (like "doesn't this leak?"
> and "shouldn't we have tests") are not addressed with the fix-up.
>
> You'll find the topic in 'seen' after I push it out for today
> perhaps in a few hours.
>
>     a981554b03 format-patch: add ability to use alt cover format
>     8bf8e6ccda format-patch: add commitListFormat config
>     a85e8e535d SQUASH???
>
> Thanks.

I found another change that is needed to make the tests pass, so the
commit object name for the squash fixup is no longer a85e8e535d;
fetching my 'seen' from any of the mirrors should let you find these
commits near the tip of 'seen'.

 builtin/log.c         | 18 ++++++++----------
 t/t9902-completion.sh |  1 +
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/builtin/log.c b/builtin/log.c
index e6ff3627b8..c531784581 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1415,7 +1415,7 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
 
 	if (skip_prefix(format, "log:", &format)) {
 		generate_commit_list_cover(rev->diffopt.file, format, list, nr);
-	} else {
+	} else if (!strcmp(format, "shortlog")) {
 		shortlog_init(&log);
 		log.wrap_lines = 1;
 		log.wrap = MAIL_DEFAULT_WRAP;
@@ -1428,6 +1428,8 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,
 			shortlog_add_commit(&log, list[i]);
 
 		shortlog_output(&log);
+	} else {
+		die(_("--cover-letter: invalid format spec '%s'"), format);
 	}
 
 	/* We can only do diffstat with a unique reference point */
@@ -1946,7 +1948,7 @@ int cmd_format_patch(int argc,
 	int just_numbers = 0;
 	int ignore_if_in_upstream = 0;
 	int cover_letter = -1;
-	char *cover_letter_fmt = NULL;
+	const char *cover_letter_fmt = NULL;
 	int boundary_count = 0;
 	int no_binary_diff = 0;
 	int zero_commit = 0;
@@ -2333,12 +2335,11 @@ int cmd_format_patch(int argc,
 		goto done;
 	total = list.nr;
 
-	if (cover_letter_fmt && (strcmp(cover_letter_fmt, "shortlog") && strncmp(cover_letter_fmt, "log:", 4))) {
-		die(_("--cover-letter: invalid format spec"));
-	}
-
-	if (!cover_letter_fmt)
+	if (!cover_letter_fmt) {
 		cover_letter_fmt = cfg.fmt_cover_letter_commit_list;
+		if (!cover_letter_fmt)
+			cover_letter_fmt = "shortlog";
+	}
 
 	if (cover_letter == -1) {
 		if (cfg.config_cover_letter == COVER_AUTO)
@@ -2427,9 +2428,6 @@ int cmd_format_patch(int argc,
 	rev.numbered_files = just_numbers;
 	rev.patch_suffix = fmt_patch_suffix;
 
-	if (cover_letter && !cover_letter_fmt)
-		cover_letter_fmt = "shortlog";
-
 	if (cover_letter) {
 		if (cfg.thread)
 			gen_message_id(&rev, "cover");
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 964e1f1569..4f760a7468 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2774,6 +2774,7 @@ test_expect_success PERL 'send-email' '
 	test_completion "git send-email --cov" <<-\EOF &&
 	--cover-from-description=Z
 	--cover-letter Z
+	--cover-letter-format=Z
 	EOF
 	test_completion "git send-email --val" <<-\EOF &&
 	--validate Z
-- 
2.53.0-485-gd48bbca10f