From 348aa94ee0d2ce645bd7504ba8e21090fb9c5797 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 13:05:44 -1000 Subject: Name the followed path in the diffstat header With follow set the diff runs over the whole commit and show_filepair applies the path, so the header read (limited to '') whether or not a path was given. --- source/ui-diff.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/ui-diff.c') diff --git a/source/ui-diff.c b/source/ui-diff.c index 958d6e7..c696ab1 100644 --- a/source/ui-diff.c +++ b/source/ui-diff.c @@ -431,16 +431,20 @@ static void inspect_filepair(struct diff_filepair *pair) total_rems += lines_removed; } +/* + * The header names the path the request gave, which under follow is applied + * by show_filepair while the walk itself runs over the whole commit. + */ static void print_diffstat(const struct object_id *old_oid, const struct object_id *new_oid, - const char *prefix) + const char *prefix, const char *path) { int i; html("
"); cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.oid, ctx.qry.oid2, NULL); - if (prefix) { + if (path) { html(" (limited to '"); - html_txt(prefix); + html_txt(path); html("')"); } html("
\n"); @@ -659,7 +663,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi if (difftype == DIFF_STATONLY) ctx.qry.difftype = ctx.cfg.difftype; - print_diffstat(old_rev_oid, new_rev_oid, prefix); + print_diffstat(old_rev_oid, new_rev_oid, prefix, path); if (difftype == DIFF_STATONLY) { if (show_ctrls) -- cgit 2.12.1