aboutsummaryrefslogtreecommitdiffstats
path: root/ui-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-tree.c')
-rw-r--r--ui-tree.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/ui-tree.c b/ui-tree.c
index aebe145..aa5dee9 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -129,14 +129,14 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
129{ 129{
130 struct walk_tree_context *walk_tree_ctx = cbdata; 130 struct walk_tree_context *walk_tree_ctx = cbdata;
131 char *name; 131 char *name;
132 char *fullpath; 132 struct strbuf fullpath = STRBUF_INIT;
133 char *class; 133 struct strbuf class = STRBUF_INIT;
134 enum object_type type; 134 enum object_type type;
135 unsigned long size = 0; 135 unsigned long size = 0;
136 136
137 name = xstrdup(pathname); 137 name = xstrdup(pathname);
138 fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", 138 strbuf_addf(&fullpath, "%s%s%s", ctx.qry.path ? ctx.qry.path : "",
139 ctx.qry.path ? "/" : "", name); 139 ctx.qry.path ? "/" : "", name);
140 140
141 if (!S_ISGITLINK(mode)) { 141 if (!S_ISGITLINK(mode)) {
142 type = sha1_object_info(sha1, &size); 142 type = sha1_object_info(sha1, &size);
@@ -152,33 +152,34 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
152 cgit_print_filemode(mode); 152 cgit_print_filemode(mode);
153 html("</td><td>"); 153 html("</td><td>");
154 if (S_ISGITLINK(mode)) { 154 if (S_ISGITLINK(mode)) {
155 cgit_submodule_link("ls-mod", fullpath, sha1_to_hex(sha1)); 155 cgit_submodule_link("ls-mod", fullpath.buf, sha1_to_hex(sha1));
156 } else if (S_ISDIR(mode)) { 156 } else if (S_ISDIR(mode)) {
157 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, 157 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head,
158 walk_tree_ctx->curr_rev, fullpath); 158 walk_tree_ctx->curr_rev, fullpath.buf);
159 } else { 159 } else {
160 class = strrchr(name, '.'); 160 char *ext = strrchr(name, '.');
161 if (class != NULL) { 161 strbuf_addstr(&class, "ls-blob");
162 class = fmt("ls-blob %s", class + 1); 162 if (ext)
163 } else 163 strbuf_addf(&class, " %s", ext + 1);
164 class = "ls-blob"; 164 cgit_tree_link(name, NULL, class.buf, ctx.qry.head,
165 cgit_tree_link(name, NULL, class, ctx.qry.head, 165 walk_tree_ctx->curr_rev, fullpath.buf);
166 walk_tree_ctx->curr_rev, fullpath);
167 } 166 }
168 htmlf("</td><td class='ls-size'>%li</td>", size); 167 htmlf("</td><td class='ls-size'>%li</td>", size);
169 168
170 html("<td>"); 169 html("<td>");
171 cgit_log_link("log", NULL, "button", ctx.qry.head, 170 cgit_log_link("log", NULL, "button", ctx.qry.head,
172 walk_tree_ctx->curr_rev, fullpath, 0, NULL, NULL, 171 walk_tree_ctx->curr_rev, fullpath.buf, 0, NULL, NULL,
173 ctx.qry.showmsg); 172 ctx.qry.showmsg);
174 if (ctx.repo->max_stats) 173 if (ctx.repo->max_stats)
175 cgit_stats_link("stats", NULL, "button", ctx.qry.head, 174 cgit_stats_link("stats", NULL, "button", ctx.qry.head,
176 fullpath); 175 fullpath.buf);
177 if (!S_ISGITLINK(mode)) 176 if (!S_ISGITLINK(mode))
178 cgit_plain_link("plain", NULL, "button", ctx.qry.head, 177 cgit_plain_link("plain", NULL, "button", ctx.qry.head,
179 walk_tree_ctx->curr_rev, fullpath); 178 walk_tree_ctx->curr_rev, fullpath.buf);
180 html("</td></tr>\n"); 179 html("</td></tr>\n");
181 free(name); 180 free(name);
181 strbuf_release(&fullpath);
182 strbuf_release(&class);
182 return 0; 183 return 0;
183} 184}
184 185