From ad5445ba9ff8e1ba03bf68cc107e8ff45c1bbafd Mon Sep 17 00:00:00 2001 From: Katalin Rebhan Date: Fri, 9 May 2025 18:39:36 +0200 Subject: Show change-id header content if present --- cgit.h | 1 + parsing.c | 14 ++++++++++++-- shared.c | 3 +++ ui-commit.c | 8 ++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/cgit.h b/cgit.h index b6bedd3..9a7d495 100644 --- a/cgit.h +++ b/cgit.h @@ -142,6 +142,7 @@ struct commitinfo { char *subject; char *msg; char *msg_encoding; + char *change_id; }; struct taginfo { diff --git a/parsing.c b/parsing.c index 115ce81..2274dd7 100644 --- a/parsing.c +++ b/parsing.c @@ -169,8 +169,18 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) if (!ret->msg_encoding) ret->msg_encoding = xstrdup("UTF-8"); - while (!end_of_header(p)) - p = next_header_line(p); + while (!end_of_header(p)) { + if (p && skip_prefix(p, "change-id ", &p)) { + t = strchr(p, '\n'); + if (t) { + ret->change_id = substr(p, t + 1); + p = t + 1; + } + } else { + p = next_header_line(p); + } + } + while (p && *p == '\n') p++; if (!p) diff --git a/shared.c b/shared.c index 07b38ba..86be047 100644 --- a/shared.c +++ b/shared.c @@ -108,6 +108,9 @@ void cgit_free_commitinfo(struct commitinfo *info) free(info->subject); free(info->msg); free(info->msg_encoding); + if (info->change_id) { + free(info->change_id); + } free(info); } diff --git a/ui-commit.c b/ui-commit.c index 5536ffc..12de4c7 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -73,7 +73,15 @@ void cgit_print_commit(char *hex, const char *prefix) html_txt(show_date(info->committer_date, info->committer_tz, cgit_date_mode(DATE_ISO8601))); html("\n"); + + if (info->change_id) { + html("change"); + html_txt(info->change_id); + html("\n"); + } + html("commit"); + tmp = oid_to_hex(&commit->object.oid); cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix); html(" ("); -- cgit 1.5.1