From 3896a932657d209ddf4a3e72f701197ae0b27361 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Mon, 24 Aug 2026 15:33:32 -1000 Subject: Fix the submodule rows in the tree listing A submodule row linked to a path with its trailing slash stripped, was labelled by its path rather than its entry name, shared the name's element with its hash, claimed a size of zero and offered a blame button that cannot work on a gitlink. --- source/ui-shared.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'source/ui-shared.c') diff --git a/source/ui-shared.c b/source/ui-shared.c index 05fa30b..02352bf 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -1032,7 +1032,8 @@ void cgit_submodule_link(const char *class, char *path, const char *rev) { struct string_list *list; struct string_list_item *item; - char tail, *dir; + char tail; + const char *name; size_t len; len = 0; @@ -1047,6 +1048,12 @@ void cgit_submodule_link(const char *class, char *path, const char *rev) item = lookup_path(list, path); } } + + // The row shows the entry's own name, like every other row, while + // the lookups above want the full path. + name = strrchr(path, '/'); + name = name ? name + 1 : path; + if (item || ctx.repo->module_link) { html("util, args, 1); } else { - const char *args[2]; - dir = strrchr(path, '/'); - if (dir) - dir++; - else - dir = path; - args[0] = dir; - args[1] = rev; + const char *args[] = { name, rev }; emit_module_link(ctx.repo->module_link, args, 2); } html("'>"); - html_txt(path); + html_txt(name); html(""); } else { html(""); - html_txt(path); + html_txt(name); html(""); } - html_txtf(" @ %.7s", rev); - if (item && tail) + html(" @ "); + html_txtf("%.7s", rev); + html(""); + if (tail == '/') path[len - 1] = tail; } -- cgit v2.8.0