git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] pretty: add X-Change-ID to mail formats

From
DDDrew DeVault <drew@ddevault.org>
Date
Jul 3, 2025, 07:45 UTC
Message-ID
<20250703074952.20737-1-drew@ddevault.org>

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
Next: Remo Senekowitsch
Message 1 of 3 in “pretty: add X-Change-ID to mail formats”
  1. pretty: add X-Change-ID to mail formatsDrew DeVault, Jul 3, 2025
  2. Remo SenekowitschJul 3, 2025
  3. Drew DeVaultJul 3, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.