|
diff --git a/ui-tree.c b/ui-tree.c index b00670e..60f7560 100644 --- a/ ui-tree.c+++ b/ ui-tree.c |
|
@@ -5,55 +5,57 @@ |
5 | * Licensed under GNU General Public License v2 |
5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) |
6 | * (see COPYING for full license text) |
7 | */ |
7 | */ |
8 | |
8 | |
9 | #include "cgit.h" |
9 | #include "cgit.h" |
10 | |
10 | |
11 | |
11 | |
12 | static int print_entry(const unsigned char *sha1, const char *base, |
12 | static int print_entry(const unsigned char *sha1, const char *base, |
13 | int baselen, const char *pathname, unsigned int mode, |
13 | int baselen, const char *pathname, unsigned int mode, |
14 | int stage) |
14 | int stage) |
15 | { |
15 | { |
16 | char *name; |
16 | char *name; |
17 | char type[20]; |
17 | enum object_type type; |
18 | unsigned long size; |
18 | unsigned long size; |
19 | |
19 | |
20 | if (sha1_object_info(sha1, type, &size)) { |
20 | name = xstrdup(pathname); |
21 | cgit_print_error(fmt("Bad object name: %s", |
21 | type = sha1_object_info(sha1, &size); |
22 | sha1_to_hex(sha1))); |
22 | if (type == OBJ_BAD) { |
| |
23 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", |
| |
24 | name, |
| |
25 | sha1_to_hex(sha1)); |
23 | return 0; |
26 | return 0; |
24 | } |
27 | } |
25 | name = xstrdup(pathname); |
| |
26 | html("<tr><td class='filemode'>"); |
28 | html("<tr><td class='filemode'>"); |
27 | html_filemode(mode); |
29 | html_filemode(mode); |
28 | html("</td><td>"); |
30 | html("</td><td>"); |
29 | if (S_ISDIR(mode)) { |
31 | if (S_ISDIRLNK(mode)) { |
| |
32 | htmlf("<div class='ls-dirlnk'>%s => submodule</div>", name); |
| |
33 | } else if (S_ISDIR(mode)) { |
30 | html("<div class='ls-dir'><a href='"); |
34 | html("<div class='ls-dir'><a href='"); |
31 | html_attr(cgit_pageurl(cgit_query_repo, "tree", |
35 | html_attr(cgit_pageurl(cgit_query_repo, "tree", |
32 | fmt("id=%s&path=%s%s/", |
36 | fmt("id=%s&path=%s%s/", |
33 | sha1_to_hex(sha1), |
37 | sha1_to_hex(sha1), |
34 | cgit_query_path ? cgit_query_path : "", |
38 | cgit_query_path ? cgit_query_path : "", |
35 | pathname))); |
39 | pathname))); |
| |
40 | htmlf("'>%s</a></div>", name); |
36 | } else { |
41 | } else { |
37 | html("<div class='ls-blob'><a href='"); |
42 | html("<div class='ls-blob'><a href='"); |
38 | html_attr(cgit_pageurl(cgit_query_repo, "view", |
43 | html_attr(cgit_pageurl(cgit_query_repo, "view", |
39 | fmt("id=%s&path=%s%s", sha1_to_hex(sha1), |
44 | fmt("id=%s&path=%s%s", sha1_to_hex(sha1), |
40 | cgit_query_path ? cgit_query_path : "", |
45 | cgit_query_path ? cgit_query_path : "", |
41 | pathname))); |
46 | pathname))); |
| |
47 | htmlf("'>%s</a></div>", name); |
42 | } |
48 | } |
43 | html("'>"); |
49 | html("</div></td>"); |
44 | html_txt(name); |
| |
45 | if (S_ISDIR(mode)) |
| |
46 | html("/"); |
| |
47 | html("</a></div></td>"); |
| |
48 | htmlf("<td class='filesize'>%li</td>", size); |
50 | htmlf("<td class='filesize'>%li</td>", size); |
49 | html("</tr>\n"); |
51 | html("</tr>\n"); |
50 | free(name); |
52 | free(name); |
51 | return 0; |
53 | return 0; |
52 | } |
54 | } |
53 | |
55 | |
54 | void cgit_print_tree(const char *hex, char *path) |
56 | void cgit_print_tree(const char *hex, char *path) |
55 | { |
57 | { |
56 | struct tree *tree; |
58 | struct tree *tree; |
57 | unsigned char sha1[20]; |
59 | unsigned char sha1[20]; |
58 | |
60 | |
59 | if (get_sha1_hex(hex, sha1)) { |
61 | if (get_sha1_hex(hex, sha1)) { |
|