From f584687e9dbb21199a7462d8642b582a722a295e Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 17 Oct 2026 12:53:17 -1000 Subject: Close the tree row when a link target is unreadable The row stopped at the error and left its cells open, so the rest of the listing rendered inside it. --- source/ui-tree.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'source/ui-tree.c') diff --git a/source/ui-tree.c b/source/ui-tree.c index 58bd7f0..c030134 100644 --- a/source/ui-tree.c +++ b/source/ui-tree.c @@ -329,19 +329,23 @@ static void print_ls_row(const struct object_id *oid, const char *pathname, if (S_ISLNK(mode) && size <= PATH_MAX) { html(" -> "); buf = odb_read_object(the_repository->objects, oid, &type, &size); + // An unreadable target stands in for the link, and the rest of + // the row still goes out so the table stays whole. if (!buf) { htmlf("Unable to read object %s", oid_to_hex(oid)); - goto cleanup; + } else { + strbuf_addbuf(&linkpath, &fullpath); + strbuf_addf(&linkpath, "/../%s", buf); + // A target climbing above the tree root has nothing to + // link to. + if (strbuf_normalize_path(&linkpath)) + html_txt(buf); + else + cgit_tree_link(buf, NULL, class.buf, ctx.qry.head, walk->rev, + linkpath.buf); + free(buf); + strbuf_release(&linkpath); } - strbuf_addbuf(&linkpath, &fullpath); - strbuf_addf(&linkpath, "/../%s", buf); - // A target climbing above the tree root has nothing to link to. - if (strbuf_normalize_path(&linkpath)) - html_txt(buf); - else - cgit_tree_link(buf, NULL, class.buf, ctx.qry.head, walk->rev, linkpath.buf); - free(buf); - strbuf_release(&linkpath); } if (S_ISGITLINK(mode)) html("-"); -- cgit