git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] pretty: add X-Change-ID to mail formats
@ 2025-07-03 11:29 Drew DeVault
  2025-07-03 11:29 ` [PATCH v2 2/2] am: import X-Change-ID from email headers Drew DeVault
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Drew DeVault @ 2025-07-03 11:29 UTC (permalink / raw)
  To: git
  Cc: Drew DeVault, Martin von Zweigbergk, Patrick Steinhardt,
	Andy Koppe, Remo Senekowitsch

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>
---
v2 is unchanged from v1.

One remark that occurs to me upon spinning v2 is that I'm not sure how
to test this behavior. There is no obvious way to cause git upstream to
produce a commit with a change-id -- presently these are only ever added
by third-party tools.

 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


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2025-08-21  8:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03 11:29 [PATCH v2 1/2] pretty: add X-Change-ID to mail formats Drew DeVault
2025-07-03 11:29 ` [PATCH v2 2/2] am: import X-Change-ID from email headers Drew DeVault
2025-07-06  3:37 ` [PATCH v2 1/2] pretty: add X-Change-ID to mail formats Jeff King
2025-07-06 10:46   ` Drew DeVault
2025-07-06  6:20 ` Aditya Garg
2025-07-06 10:41   ` Drew DeVault
2025-07-07  1:30     ` Junio C Hamano
2025-07-07  5:53       ` Junio C Hamano
2025-07-07  6:57         ` Martin von Zweigbergk
2025-07-07  6:59           ` Martin von Zweigbergk
2025-07-07 12:40             ` Junio C Hamano
2025-07-07  7:12           ` Drew DeVault
2025-07-07  7:09       ` Drew DeVault
2025-08-19 17:45 ` Remo Senekowitsch
2025-08-20  7:29   ` Drew DeVault
2025-08-21  0:50     ` Junio C Hamano
2025-08-21  8:52       ` Drew DeVault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).