Re: [PATCH v2 1/2] format-patch: add ability to use alt cover format
- From
Jeff King <peff@peff.net>
- Date
- Feb 25, 2026, 13:56 UTC
- Message-ID
- <20260225135628.GD2139176@coredump.intra.peff.net>
- In-Reply-To
- <66cac565f8a40f8de3dc3d857feb681bb80cb136.1771925291.git.mroik@delayed.space>
On Tue, Feb 24, 2026 at 10:29:01AM +0100, Mirko Faina wrote:
Show 13 quoted lines
> +static void generate_commit_list_cover(FILE *cover_file,const char *format,
> + struct commit **list, int n)
> +{
> + struct strbuf commit_line = STRBUF_INIT;
> + struct pretty_print_context ctx = {0};
> +
> + strbuf_init(&commit_line, 0);
> + for (int i = n - 1; i >= 0; i--) {
> + strbuf_addf(&commit_line, "[%0*d/%d] ", decimal_width(n), n - i, n);
> + repo_format_commit_message(the_repository, list[i], format, &commit_line, &ctx);
> + fprintf(cover_file, "%s\n", commit_line.buf);
> + strbuf_reset(&commit_line);
> + }When this topic came up initially I imagined that the user would be able to tweak the "[1/5]" part of the string, too. It would take a little extra work, though:
- introduce new placeholders like %(count) and %(total) or similar
- introduce count/total fields to pretty_print_context
- probably when total is unset, refuse to interpret %(count) and
%(total) at all (so they do not have meaning for regular "git log
--format" calls. - not sure how to handle the width field for the count. Would it have
an option to default to the width of the total field?But I'm not sure if it is worth all of that effort. It is more flexible, but would people really want to customize how it is shown (after all, I don't think we allow configuring it in the patch subjects themselves, though we do allow suppressing the "[PATCH]" part completely).
I had a few other comments while reading the patch, but Junio already made them for me. :) I do like the direction this is heading.
-Peff