From ba066ae56395d481d669d69c4ad14d9a268c0762 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 1 Nov 2026 10:18:08 -1000 Subject: Lead a blame page's folder crumbs to the tree --- source/ui-shared.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/ui-shared.c b/source/ui-shared.c index 23daa2b..0eeda44 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -618,6 +618,21 @@ static void self_link(const char *name, const char *title, const char *class) reporevlink(ctx.qry.page, name, title, class, ctx.qry.head, NULL, ctx.qry.path); } +/* + * A crumb leads to the same page for the prefix it stands for, except that + * blame takes a file alone, so on that page a folder's crumb leads to the + * tree. + */ +static void crumb_link(const char *name, int folder) +{ + const char *rev = ctx.qry.has_oid ? ctx.qry.oid : NULL; + + if (folder && !strcmp(ctx.qry.page, "blame")) + cgit_tree_link(name, NULL, NULL, ctx.qry.head, rev, ctx.qry.path); + else + self_link(name, NULL, NULL); +} + static void print_path_crumbs(char *path) { char *old_path = ctx.qry.path; @@ -625,7 +640,7 @@ static void print_path_crumbs(char *path) int levels = 0; ctx.qry.path = NULL; - self_link("root", NULL, NULL); + crumb_link("root", 1); // self_link reads the path out of ctx.qry, so terminating the buffer at // each slash is what makes a crumb link to the prefix it stands for. ctx.qry.path = start = path; @@ -634,7 +649,7 @@ static void print_path_crumbs(char *path) slash = end; *slash = '\0'; html_txt("/"); - self_link(start, NULL, NULL); + crumb_link(start, slash < end); if (slash < end) *slash = '/'; start = slash + 1; -- cgit 2.12.1