All of lore.kernel.org
 help / color / mirror / Atom feed
From: Drew DeVault <drew@ddevault.org>
To: git@vger.kernel.org
Cc: Drew DeVault <drew@ddevault.org>,
	Martin von Zweigbergk <martinvonz@google.com>,
	Patrick Steinhardt <ps@pks.im>, Andy Koppe <andy.koppe@gmail.com>,
	"Remo Senekowitsch" <remo@buenzli.dev>
Subject: [PATCH] pretty: add X-Change-ID to mail formats
Date: Thu,  3 Jul 2025 09:45:29 +0200	[thread overview]
Message-ID: <20250703074952.20737-1-drew@ddevault.org> (raw)

Introduce the X-Change-ID header to emails prepared by git (i.e. via
format-patch, send-email). This allows tools which work with those
emails (e.g. patchwork, sourcehut) to meaningfully integrate with tools
that assign change IDs to commits.

With some follow-up work, this is also the first step towards ensuring
that those change IDs are preserved through from git-send-email to
git-am as a change moves through its review lifecycle.

Signed-off-by: Drew DeVault <drew@ddevault.org>
---
I have refrained from implementing the git-am part of this work for now,
on the basis that I'm not sure how downstream tools like Jujutsu would
feel if git wrote the change-id header to new commits. Would that
conflict with some internal deterministic process for coming up with the
change-id that could come up with a different answer, leading to
conflicts? I don't know, so I would appreciate some insights from those
who understand the implications for their downstream systems.

Adding the change ID to outgoing emails is useful on its own, however,
so I think this patch is acceptable without the git-am side being
initially present.

 pretty.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/pretty.c b/pretty.c
index 0bc8ad8a9a..70fba7b023 100644
--- a/pretty.c
+++ b/pretty.c
@@ -2045,7 +2045,7 @@ static void pp_header(struct pretty_print_context *pp,
 	int parents_shown = 0;
 
 	for (;;) {
-		const char *name, *line = *msg_p;
+		const char *name, *change_id, *line = *msg_p;
 		int linelen = get_one_line(*msg_p);
 
 		if (!linelen)
@@ -2089,6 +2089,11 @@ static void pp_header(struct pretty_print_context *pp,
 			strbuf_grow(sb, linelen + 80);
 			pp_user_info(pp, "Commit", sb, name, encoding);
 		}
+		if (skip_prefix(line, "change-id ", &change_id) &&
+		    cmit_fmt_is_mail(pp->fmt)) {
+			strbuf_addf(sb, "X-Change-ID: %.*s\n",
+				    linelen - 11, change_id);
+		}
 	}
 }
 
-- 
2.50.0


             reply	other threads:[~2025-07-03  8:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03  7:45 Drew DeVault [this message]
2025-07-03  8:41 ` [PATCH] pretty: add X-Change-ID to mail formats Remo Senekowitsch
2025-07-03 11:32   ` Drew DeVault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250703074952.20737-1-drew@ddevault.org \
    --to=drew@ddevault.org \
    --cc=andy.koppe@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=martinvonz@google.com \
    --cc=ps@pks.im \
    --cc=remo@buenzli.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.