author | Lars Hjemli <hjemli@gmail.com> | 2007-05-08 20:40:59 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-05-08 21:38:49 (UTC) |
commit | 61c3ca978c586c673aec618cb94210657278dda8 (patch) (unidiff) | |
tree | 7011987769e65ad0e7aa8b79f648357e9cd88c30 /ui-tree.c | |
parent | 66cacd053ba900c8eb3b7962027370c84a97f990 (diff) | |
download | cgit-61c3ca978c586c673aec618cb94210657278dda8.zip cgit-61c3ca978c586c673aec618cb94210657278dda8.tar.gz cgit-61c3ca978c586c673aec618cb94210657278dda8.tar.bz2 |
Update to libgit 1.5.2-rc2
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-tree.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -1,78 +1,80 @@ | |||
1 | /* ui-tree.c: functions for tree output | 1 | /* ui-tree.c: functions for tree output |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
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)) { |
60 | cgit_print_error(fmt("Invalid object id: %s", hex)); | 62 | cgit_print_error(fmt("Invalid object id: %s", hex)); |
61 | return; | 63 | return; |
62 | } | 64 | } |
63 | tree = parse_tree_indirect(sha1); | 65 | tree = parse_tree_indirect(sha1); |
64 | if (!tree) { | 66 | if (!tree) { |
65 | cgit_print_error(fmt("Not a tree object: %s", hex)); | 67 | cgit_print_error(fmt("Not a tree object: %s", hex)); |
66 | return; | 68 | return; |
67 | } | 69 | } |
68 | 70 | ||
69 | html_txt(path); | 71 | html_txt(path); |
70 | html("<table class='list'>\n"); | 72 | html("<table class='list'>\n"); |
71 | html("<tr class='nohover'>"); | 73 | html("<tr class='nohover'>"); |
72 | html("<th class='left'>Mode</th>"); | 74 | html("<th class='left'>Mode</th>"); |
73 | html("<th class='left'>Name</th>"); | 75 | html("<th class='left'>Name</th>"); |
74 | html("<th class='right'>Size</th>"); | 76 | html("<th class='right'>Size</th>"); |
75 | html("</tr>\n"); | 77 | html("</tr>\n"); |
76 | read_tree_recursive(tree, "", 0, 1, NULL, print_entry); | 78 | read_tree_recursive(tree, "", 0, 1, NULL, print_entry); |
77 | html("</table>\n"); | 79 | html("</table>\n"); |
78 | } | 80 | } |