{"thread":{"id":"65190","subject":"[GSoC PATCH] format-patch: write numbered list in cover letter","startedAt":"2026-03-10T04:19:35Z","lastAt":"2026-03-10T15:05:52Z","messageCount":3,"participants":["Pablo Sabater","Junio C Hamano","Pablo"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"538354","messageId":"20260310041929.1687483-1-pabloosabaterr@gmail.com","threadId":"65190","inReplyTo":null,"subject":"[GSoC PATCH] format-patch: write numbered list in cover letter","fromName":"Pablo Sabater","fromEmail":"pabloosabaterr@gmail.com","sentAt":"2026-03-10T04:19:29Z","receivedAt":"2026-03-10T04:19:35Z","isPatch":true,"sender":{"key":"pabloosabaterr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/63864637?v=4"},"body":"Cover letter generated with 'git format-patch --cover-letter' uses\nshortlog grouping commits by author. For a single author patch grouping\nby author add useless information and makes it hard to follow patch\nreferences: \"second patch does x and y patch does z\"\n\nReplace the shortlog with a numbered list of patches:\n\n  [1/2]: first commit\n  [2/2]: second commit\n\nshortlog grouping by author is lost, both for single author patches\nand multiple author patches\n\nsuggested as #leftoverbits by Junio C Hamano at\nhttps://lore.kernel.org/git/xmqqbjhjxp2d.fsf@gitster.g/\n\nSigned-off-by: Pablo Sabater <pabloosabaterr@gmail.com>\n---\nI haven't tried to group by author on multiple authors patches to keep it simple \nbut I believe it's doable.\n\n Documentation/git-format-patch.adoc           |  5 ++--\n builtin/log.c                                 | 26 +++++++++----------\n ..._--stdout_--cover-letter_-n_initial..main^ |  5 ++--\n t/t4014-format-patch.sh                       | 16 +++---------\n 4 files changed, 21 insertions(+), 31 deletions(-)\n\ndiff --git a/Documentation/git-format-patch.adoc b/Documentation/git-format-patch.adoc\nindex 36146006fa..420f05099c 100644\n--- a/Documentation/git-format-patch.adoc\n+++ b/Documentation/git-format-patch.adoc\n@@ -319,8 +319,9 @@ feeding the result to `git send-email`.\n --cover-letter::\n --no-cover-letter::\n \tIn addition to the patches, generate a cover letter file\n-\tcontaining the branch description, shortlog and the overall diffstat.  You can\n-\tfill in a description in the file before sending it out.\n+\tcontaining the branch description, numbered [n/m] list of patches and\n+\tthe overall diffstat.  You can fill in a description in the file before\n+\tsending it out.\n \n --encode-email-headers::\n --no-encode-email-headers::\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 7cb919bca9..002af4fa59 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1332,7 +1332,6 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \t\t\t      const struct format_config *cfg)\n {\n \tconst char *from;\n-\tstruct shortlog log;\n \tstruct strbuf sb = STRBUF_INIT;\n \tint i;\n \tconst char *encoding = \"UTF-8\";\n@@ -1340,6 +1339,8 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \tstruct pretty_print_context pp = {0};\n \tstruct commit *head = list[0];\n \tchar *to_free = NULL;\n+\tstruct strbuf oneline = STRBUF_INIT;\n+\tstruct pretty_print_context ctx = {0};\n \n \tif (!cmit_fmt_is_mail(rev->commit_format))\n \t\tdie(_(\"cover letter needs email format\"));\n@@ -1376,18 +1377,17 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file,\n \tfree(pp.after_subject);\n \tstrbuf_release(&sb);\n \n-\tshortlog_init(&log);\n-\tlog.wrap_lines = 1;\n-\tlog.wrap = MAIL_DEFAULT_WRAP;\n-\tlog.in1 = 2;\n-\tlog.in2 = 4;\n-\tlog.file = rev->diffopt.file;\n-\tlog.groups = SHORTLOG_GROUP_AUTHOR;\n-\tshortlog_finish_setup(&log);\n-\tfor (i = 0; i < nr; i++)\n-\t\tshortlog_add_commit(&log, list[i]);\n-\n-\tshortlog_output(&log);\n+\tctx.fmt = CMIT_FMT_USERFORMAT;\n+\tctx.output_encoding = get_log_output_encoding();\n+\n+\tfor (i = nr - 1; i >= 0; i--) {\n+\t\tstrbuf_reset(&oneline);\n+\t\trepo_format_commit_message(the_repository, list[i], \"%s\", &oneline, &ctx);\n+\t\tfprintf(rev->diffopt.file, \"  [%d/%d]: %s\\n\", nr - i, nr, oneline.buf);\n+\t}\n+\tfprintf(rev->diffopt.file, \"\\n\");\n+\n+\tstrbuf_release(&oneline);\n \n \t/* We can only do diffstat with a unique reference point */\n \tif (origin)\ndiff --git a/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..main^ b/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..main^\nindex 567f222198..ad78528e1e 100644\n--- a/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..main^\n+++ b/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..main^\n@@ -6,9 +6,8 @@ Subject: [DIFFERENT_PREFIX 0/2] *** SUBJECT HERE ***\n \n *** BLURB HERE ***\n \n-A U Thor (2):\n-  Second\n-  Third\n+  [1/2]: Second\n+  [2/2]: Third\n \n  dir/sub | 4 ++++\n  file0   | 3 +++\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 2135b65cee..3ffccb8ee8 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -693,20 +693,10 @@ test_expect_success 'cover-letter inherits diff options' '\n \tgrep \"file => foo .* 0 *\\$\" 0000-cover-letter.patch\n '\n \n-cat >expect <<EOF\n-  This is an excessively long subject line for a message due to the\n-    habit some projects have of not having a short, one-line subject at\n-    the start of the commit message, but rather sticking a whole\n-    paragraph right at the start as the only thing in the commit\n-    message. It had better not become the filename for the patch.\n-  foo\n-\n-EOF\n-\n-test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '\n+test_expect_success 'cover-letter lists patches in numbered format' '\n \tgit format-patch --cover-letter -2 &&\n-\tsed -e \"1,/A U Thor/d\" -e \"/^\\$/q\" 0000-cover-letter.patch >output &&\n-\ttest_cmp expect output\n+\tgrep \"^  \\[1/2\\]:\" 0000-cover-letter.patch &&\n+\tgrep \"^  \\[2/2\\]:\" 0000-cover-letter.patch\n '\n \n cat >expect <<EOF\n-- \n2.43.0\n\n"},{"id":"538357","messageId":"xmqqo6kwxp17.fsf@gitster.g","threadId":"65190","inReplyTo":"20260310041929.1687483-1-pabloosabaterr@gmail.com","subject":"Re: [GSoC PATCH] format-patch: write numbered list in cover letter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-10T04:54:28Z","receivedAt":"2026-03-10T04:54:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pablo Sabater <pabloosabaterr@gmail.com> writes:\n\n> Cover letter generated with 'git format-patch --cover-letter' uses\n> shortlog grouping commits by author. For a single author patch grouping\n> by author add useless information and makes it hard to follow patch\n> references: \"second patch does x and y patch does z\"\n>\n> Replace the shortlog with a numbered list of patches:\n>\n>   [1/2]: first commit\n>   [2/2]: second commit\n>\n> shortlog grouping by author is lost, both for single author patches\n> and multiple author patches\n>\n> suggested as #leftoverbits by Junio C Hamano at\n> https://lore.kernel.org/git/xmqqbjhjxp2d.fsf@gitster.g/\n>\n> Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>\n> ---\n> I haven't tried to group by author on multiple authors patches to keep it simple \n> but I believe it's doable.\n\nHow does this compare with\n\n  https://lore.kernel.org/git/cover.1772839973.git.mroik@delayed.space/\n\nI wonder.\n"},{"id":"538458","messageId":"CAN5EUNRmXQZGj-3AxrdCmuxNwPfr3gBQkNMsvvjSgC2sZYFeZg@mail.gmail.com","threadId":"65190","inReplyTo":"xmqqo6kwxp17.fsf@gitster.g","subject":"Re: [GSoC PATCH] format-patch: write numbered list in cover letter","fromName":"Pablo","fromEmail":"pabloosabaterr@gmail.com","sentAt":"2026-03-10T15:05:35Z","receivedAt":"2026-03-10T15:05:52Z","isPatch":true,"sender":{"key":"pabloosabaterr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/63864637?v=4"},"body":"> How does this compare with\n>\n>   https://lore.kernel.org/git/cover.1772839973.git.mroik@delayed.space/\n>\n> I wonder.\n\nI'm sorry, seems I didn't double check that it wasn't already started\nby someone.\nAnd my version is way below Mirko, I'll search for another place to help\n\nPablo\n"}]}