summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2008-05-20 20:32:22 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-05-20 20:32:22 (UTC)
commit08a8757fa54ee70d31882344ca7f19de5cbe4690 (patch) (side-by-side diff)
tree93cddfcbb81bbaf0fe8b3206d5f2f9c11dc6df9a
parentdd7c172542440170b5b1aca8be43d2ad6dae7227 (diff)
downloadcgit-08a8757fa54ee70d31882344ca7f19de5cbe4690.zip
cgit-08a8757fa54ee70d31882344ca7f19de5cbe4690.tar.gz
cgit-08a8757fa54ee70d31882344ca7f19de5cbe4690.tar.bz2
ui-tree.c: avoid peeking at GITLINK objects
When an object in the tree has GITLINK mode-bits we don't need to get any more info about that particular object (and trying to get more info about it will usually generate an annoying warning on stderr since the object typically doesn't exist in the repo anyways). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (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)
html("</td></tr>\n");
start = idx + 1;
}
idx++;
}
htmlf(linefmt, ++lineno);
html_txt(buf + start);
html("</td></tr>\n");
html("</table>\n");
}
static int ls_item(const unsigned char *sha1, const char *base, int baselen,
const char *pathname, unsigned int mode, int stage)
{
char *name;
char *fullpath;
enum object_type type;
unsigned long size = 0;
name = xstrdup(pathname);
fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "",
ctx.qry.path ? "/" : "", name);
- type = sha1_object_info(sha1, &size);
- if (type == OBJ_BAD && !S_ISGITLINK(mode)) {
- htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
- name,
- sha1_to_hex(sha1));
- return 0;
+ if (!S_ISGITLINK(mode)) {
+ type = sha1_object_info(sha1, &size);
+ if (type == OBJ_BAD) {
+ htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
+ name,
+ sha1_to_hex(sha1));
+ return 0;
+ }
}
html("<tr><td class='ls-mode'>");
cgit_print_filemode(mode);
html("</td><td>");
if (S_ISGITLINK(mode)) {
htmlf("<a class='ls-mod' href='");
html_attr(fmt(ctx.repo->module_link,
name,
sha1_to_hex(sha1)));
html("'>");
html_txt(name);
html("</a>");
} else if (S_ISDIR(mode)) {
cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head,
curr_rev, fullpath);
} else {
cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head,
curr_rev, fullpath);
}
htmlf("</td><td class='ls-size'>%li</td>", size);
html("<td>");
cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev,