From: Mirko Faina Date: Thu, 12 Mar 2026 16:20:10 GMT Subject: [PATCH v8 3/4] format-patch: add "chronological" format for cover Message-ID: In-Reply-To: Having a user craft a custom format spec everytime might be a hassle, and having a common format that seems reasonable might make reviews easier. This patch introduces a new simple preset called "chronological". Teach make_cover_letter() the "chronological" format. Signed-off-by: Mirko Faina --- Documentation/git-format-patch.adoc | 2 +- builtin/log.c | 3 +++ t/t4014-format-patch.sh | 11 +++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Documentation/git-format-patch.adoc b/Documentation/git-format-patch.adoc index de36b87a85..6364fd1f5a 100644 --- a/Documentation/git-format-patch.adoc +++ b/Documentation/git-format-patch.adoc @@ -326,7 +326,7 @@ feeding the result to `git send-email`. Specify the format in which to generate the commit list of the patch series. This option is available if the user wants to use an alternative to the default `shortlog` format. The accepted values for - format-spec are "shortlog" or a format string. + format-spec are "shortlog", "chronological" or a format string. e.g. `%s (%an)` If defined, defaults to the `format.commitListFormat` configuration variable. diff --git a/builtin/log.c b/builtin/log.c index 4f22012395..12877a0ac2 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -50,6 +50,7 @@ #define MAIL_DEFAULT_WRAP 72 #define COVER_FROM_AUTO_MAX_SUBJECT_LEN 100 #define FORMAT_PATCH_NAME_MAX_DEFAULT 64 +#define CHRONOLOGICAL "[%(count)/%(total)] %s" static unsigned int force_in_body_from; static int stdout_mboxrd; @@ -1420,6 +1421,8 @@ static void make_cover_letter(struct rev_info *rev, int use_separate_file, if (format == NULL || !strcmp(format, "shortlog")) generate_shortlog_cover_letter(&log, rev, list, nr); + else if (!strcmp(format, "chronological")) + generate_commit_list_cover(rev->diffopt.file, CHRONOLOGICAL, list, nr); else generate_commit_list_cover(rev->diffopt.file, format, list, nr); diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 631669c159..5ec527bce9 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -392,6 +392,17 @@ test_expect_success 'cover letter with subject, author and count' ' test_grep "^\[1/1\] This is a subject (A U Thor)$" patches/0000-cover-letter.patch ' +test_expect_success 'cover letter chronological' ' + test_when_finished "git reset --hard HEAD~1" && + test_when_finished "rm -rf patches result test_file" && + touch test_file && + git add test_file && + git commit -m "This is a subject" && + git format-patch --cover-letter \ + --cover-letter-format="chronological" -o patches HEAD~1 && + test_grep "^\[1/1\] This is a subject$" patches/0000-cover-letter.patch +' + cat > expected <