summaryrefslogtreecommitdiffabout
path: root/ui-tree.c
Unidiff
Diffstat (limited to 'ui-tree.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-tree.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/ui-tree.c b/ui-tree.c
index 2f052c7..5a2dd3f 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -52,54 +52,56 @@ static void print_object(const unsigned char *sha1, char *path)
52 html("</td></tr>\n"); 52 html("</td></tr>\n");
53 start = idx + 1; 53 start = idx + 1;
54 } 54 }
55 idx++; 55 idx++;
56 } 56 }
57 htmlf(linefmt, ++lineno); 57 htmlf(linefmt, ++lineno);
58 html_txt(buf + start); 58 html_txt(buf + start);
59 html("</td></tr>\n"); 59 html("</td></tr>\n");
60 html("</table>\n"); 60 html("</table>\n");
61} 61}
62 62
63 63
64static int ls_item(const unsigned char *sha1, const char *base, int baselen, 64static int ls_item(const unsigned char *sha1, const char *base, int baselen,
65 const char *pathname, unsigned int mode, int stage) 65 const char *pathname, unsigned int mode, int stage)
66{ 66{
67 char *name; 67 char *name;
68 char *fullpath; 68 char *fullpath;
69 enum object_type type; 69 enum object_type type;
70 unsigned long size = 0; 70 unsigned long size = 0;
71 71
72 name = xstrdup(pathname); 72 name = xstrdup(pathname);
73 fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", 73 fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "",
74 ctx.qry.path ? "/" : "", name); 74 ctx.qry.path ? "/" : "", name);
75 75
76 type = sha1_object_info(sha1, &size); 76 if (!S_ISGITLINK(mode)) {
77 if (type == OBJ_BAD && !S_ISGITLINK(mode)) { 77 type = sha1_object_info(sha1, &size);
78 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", 78 if (type == OBJ_BAD) {
79 name, 79 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
80 sha1_to_hex(sha1)); 80 name,
81 return 0; 81 sha1_to_hex(sha1));
82 return 0;
83 }
82 } 84 }
83 85
84 html("<tr><td class='ls-mode'>"); 86 html("<tr><td class='ls-mode'>");
85 cgit_print_filemode(mode); 87 cgit_print_filemode(mode);
86 html("</td><td>"); 88 html("</td><td>");
87 if (S_ISGITLINK(mode)) { 89 if (S_ISGITLINK(mode)) {
88 htmlf("<a class='ls-mod' href='"); 90 htmlf("<a class='ls-mod' href='");
89 html_attr(fmt(ctx.repo->module_link, 91 html_attr(fmt(ctx.repo->module_link,
90 name, 92 name,
91 sha1_to_hex(sha1))); 93 sha1_to_hex(sha1)));
92 html("'>"); 94 html("'>");
93 html_txt(name); 95 html_txt(name);
94 html("</a>"); 96 html("</a>");
95 } else if (S_ISDIR(mode)) { 97 } else if (S_ISDIR(mode)) {
96 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, 98 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head,
97 curr_rev, fullpath); 99 curr_rev, fullpath);
98 } else { 100 } else {
99 cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head, 101 cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head,
100 curr_rev, fullpath); 102 curr_rev, fullpath);
101 } 103 }
102 htmlf("</td><td class='ls-size'>%li</td>", size); 104 htmlf("</td><td class='ls-size'>%li</td>", size);
103 105
104 html("<td>"); 106 html("<td>");
105 cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev, 107 cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev,