]>
git.cameronkatri.com Git - cgit.git/blob - ui-tree.c
1 /* ui-tree.c: functions for tree output
3 * Copyright (C) 2006 Lars Hjemli
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
12 static int print_entry(const unsigned char *sha1
, const char *base
,
13 int baselen
, const char *pathname
, unsigned int mode
,
20 if (sha1_object_info(sha1
, type
, &size
)) {
21 cgit_print_error(fmt("Bad object name: %s",
25 name
= xstrdup(pathname
);
28 html("<div class='ls-dir'><a href='");
29 html_attr(cgit_pageurl(cgit_query_repo
, "tree",
30 fmt("id=%s", sha1_to_hex(sha1
))));
32 html("<div class='ls-blob'><a href='");
33 html_attr(cgit_pageurl(cgit_query_repo
, "view",
34 fmt("id=%s", sha1_to_hex(sha1
))));
40 html("</a></div></td>");
41 htmlf("<td class='filesize'>%li</td>", size
);
42 htmlf("<td class='filemode'>%06o</td>", mode
);
48 void cgit_print_tree(const char *hex
)
51 unsigned char sha1
[20];
53 if (get_sha1_hex(hex
, sha1
)) {
54 cgit_print_error(fmt("Invalid object id: %s", hex
));
57 tree
= parse_tree_indirect(sha1
);
59 cgit_print_error(fmt("Not a tree object: %s", hex
));
63 html("<h2>Tree content</h2>\n");
64 html("<table class='list'>\n");
65 html("<tr><th>Name</th>");
66 html("<th class='filesize'>Size</th>");
67 html("<th class='filemode'>Mode</th></tr>\n");
68 read_tree_recursive(tree
, "", 0, 1, NULL
, print_entry
);