1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
diff --git a/ui-tree.c b/ui-tree.c
index 034c4c89474fdb7ecd6e491ab6b0e15f2529834b..98ce1ca09ab9ffb3101517db8e858878869dfe26 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -204,9 +204,11 @@ {
struct walk_tree_context *walk_tree_ctx = cbdata;
char *name;
struct strbuf fullpath = STRBUF_INIT;
+ struct strbuf linkpath = STRBUF_INIT;
struct strbuf class = STRBUF_INIT;
enum object_type type;
unsigned long size = 0;
+ char *buf;
name = xstrdup(pathname);
strbuf_addf(&fullpath, "%s%s%s", ctx.qry.path ? ctx.qry.path : "",
@@ -218,8 +220,7 @@ if (type == OBJ_BAD) {
htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
name,
oid_to_hex(oid));
- free(name);
- return 0;
+ goto cleanup;
}
}
@@ -239,6 +240,21 @@ strbuf_addf(&class, " %s", ext + 1);
cgit_tree_link(name, NULL, class.buf, ctx.qry.head,
walk_tree_ctx->curr_rev, fullpath.buf);
}
+ if (S_ISLNK(mode)) {
+ html(" -> ");
+ buf = read_object_file(oid, &type, &size);
+ if (!buf) {
+ htmlf("Error reading object: %s", oid_to_hex(oid));
+ goto cleanup;
+ }
+ strbuf_addbuf(&linkpath, &fullpath);
+ strbuf_addf(&linkpath, "/../%s", buf);
+ strbuf_normalize_path(&linkpath);
+ cgit_tree_link(buf, NULL, class.buf, ctx.qry.head,
+ walk_tree_ctx->curr_rev, linkpath.buf);
+ free(buf);
+ strbuf_release(&linkpath);
+ }
htmlf("</td><td class='ls-size'>%li</td>", size);
html("<td>");
@@ -255,6 +271,8 @@ if (!S_ISDIR(mode) && ctx.repo->enable_blame)
cgit_blame_link("blame", NULL, "button", ctx.qry.head,
walk_tree_ctx->curr_rev, fullpath.buf);
html("</td></tr>\n");
+
+cleanup:
free(name);
strbuf_release(&fullpath);
strbuf_release(&class);
|