|
diff --git a/ui-tree.c b/ui-tree.c index eb3d3ac..db0bef6 100644 --- a/ ui-tree.c+++ b/ ui-tree.c |
|
@@ -2,97 +2,96 @@ |
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 | char *curr_rev; |
11 | char *curr_rev; |
12 | char *match_path; |
12 | char *match_path; |
13 | int header = 0; |
13 | int header = 0; |
14 | |
14 | |
15 | static void print_object(const unsigned char *sha1, char *path) |
15 | static void print_object(const unsigned char *sha1, char *path) |
16 | { |
16 | { |
17 | enum object_type type; |
17 | enum object_type type; |
18 | unsigned char *buf; |
18 | unsigned char *buf; |
19 | unsigned long size, lineno, start, idx; |
19 | unsigned long size, lineno, start, idx; |
20 | |
20 | |
21 | type = sha1_object_info(sha1, &size); |
21 | type = sha1_object_info(sha1, &size); |
22 | if (type == OBJ_BAD) { |
22 | if (type == OBJ_BAD) { |
23 | cgit_print_error(fmt("Bad object name: %s", |
23 | cgit_print_error(fmt("Bad object name: %s", |
24 | sha1_to_hex(sha1))); |
24 | sha1_to_hex(sha1))); |
25 | return; |
25 | return; |
26 | } |
26 | } |
27 | |
27 | |
28 | buf = read_sha1_file(sha1, &type, &size); |
28 | buf = read_sha1_file(sha1, &type, &size); |
29 | if (!buf) { |
29 | if (!buf) { |
30 | cgit_print_error(fmt("Error reading object %s", |
30 | cgit_print_error(fmt("Error reading object %s", |
31 | sha1_to_hex(sha1))); |
31 | sha1_to_hex(sha1))); |
32 | return; |
32 | return; |
33 | } |
33 | } |
34 | |
34 | |
35 | html("<table class='blob'>\n"); |
35 | html("<table class='blob'>\n"); |
36 | idx = 0; |
36 | idx = 0; |
37 | start = 0; |
37 | start = 0; |
38 | lineno = 0; |
38 | lineno = 0; |
39 | while(idx < size) { |
39 | while(idx < size) { |
40 | if (buf[idx] == '\n') { |
40 | if (buf[idx] == '\n') { |
41 | buf[idx] = '\0'; |
41 | buf[idx] = '\0'; |
42 | htmlf("<tr><td class='no'>%d</td><td class='txt'>", |
42 | htmlf("<tr><td class='no'>%d</td><td class='txt'>", |
43 | ++lineno); |
43 | ++lineno); |
44 | html_txt(buf + start); |
44 | html_txt(buf + start); |
45 | html("</td></tr>\n"); |
45 | html("</td></tr>\n"); |
46 | start = idx + 1; |
46 | start = idx + 1; |
47 | } |
47 | } |
48 | idx++; |
48 | idx++; |
49 | } |
49 | } |
50 | html("\n</td></tr>\n"); |
| |
51 | html("</table>\n"); |
50 | html("</table>\n"); |
52 | } |
51 | } |
53 | |
52 | |
54 | |
53 | |
55 | static int ls_item(const unsigned char *sha1, const char *base, int baselen, |
54 | static int ls_item(const unsigned char *sha1, const char *base, int baselen, |
56 | const char *pathname, unsigned int mode, int stage) |
55 | const char *pathname, unsigned int mode, int stage) |
57 | { |
56 | { |
58 | char *name; |
57 | char *name; |
59 | enum object_type type; |
58 | enum object_type type; |
60 | unsigned long size = 0; |
59 | unsigned long size = 0; |
61 | char *url, *qry; |
60 | char *url, *qry; |
62 | |
61 | |
63 | name = xstrdup(pathname); |
62 | name = xstrdup(pathname); |
64 | type = sha1_object_info(sha1, &size); |
63 | type = sha1_object_info(sha1, &size); |
65 | if (type == OBJ_BAD && !S_ISDIRLNK(mode)) { |
64 | if (type == OBJ_BAD && !S_ISDIRLNK(mode)) { |
66 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", |
65 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", |
67 | name, |
66 | name, |
68 | sha1_to_hex(sha1)); |
67 | sha1_to_hex(sha1)); |
69 | return 0; |
68 | return 0; |
70 | } |
69 | } |
71 | qry = fmt("h=%s&path=%s%s%s", curr_rev, |
70 | qry = fmt("h=%s&path=%s%s%s", curr_rev, |
72 | cgit_query_path ? cgit_query_path : "", |
71 | cgit_query_path ? cgit_query_path : "", |
73 | cgit_query_path ? "/" : "", pathname); |
72 | cgit_query_path ? "/" : "", pathname); |
74 | url = cgit_pageurl(cgit_query_repo, "tree", qry); |
73 | url = cgit_pageurl(cgit_query_repo, "tree", qry); |
75 | html("<tr><td class='filemode'>"); |
74 | html("<tr><td class='filemode'>"); |
76 | html_filemode(mode); |
75 | html_filemode(mode); |
77 | html("</td><td "); |
76 | html("</td><td "); |
78 | if (S_ISDIRLNK(mode)) { |
77 | if (S_ISDIRLNK(mode)) { |
79 | htmlf("class='ls-mod'><a href='"); |
78 | htmlf("class='ls-mod'><a href='"); |
80 | html_attr(fmt(cgit_repo->module_link, |
79 | html_attr(fmt(cgit_repo->module_link, |
81 | name, |
80 | name, |
82 | sha1_to_hex(sha1))); |
81 | sha1_to_hex(sha1))); |
83 | } else if (S_ISDIR(mode)) { |
82 | } else if (S_ISDIR(mode)) { |
84 | html("class='ls-dir'><a href='"); |
83 | html("class='ls-dir'><a href='"); |
85 | html_attr(url); |
84 | html_attr(url); |
86 | } else { |
85 | } else { |
87 | html("class='ls-blob'><a href='"); |
86 | html("class='ls-blob'><a href='"); |
88 | html_attr(url); |
87 | html_attr(url); |
89 | } |
88 | } |
90 | htmlf("'>%s</a></td>", name); |
89 | htmlf("'>%s</a></td>", name); |
91 | htmlf("<td class='filesize'>%li</td>", size); |
90 | htmlf("<td class='filesize'>%li</td>", size); |
92 | |
91 | |
93 | html("<td class='links'><a href='"); |
92 | html("<td class='links'><a href='"); |
94 | qry = fmt("h=%s&path=%s%s%s", curr_rev, |
93 | qry = fmt("h=%s&path=%s%s%s", curr_rev, |
95 | cgit_query_path ? cgit_query_path : "", |
94 | cgit_query_path ? cgit_query_path : "", |
96 | cgit_query_path ? "/" : "", pathname); |
95 | cgit_query_path ? "/" : "", pathname); |
97 | url = cgit_pageurl(cgit_query_repo, "log", qry); |
96 | url = cgit_pageurl(cgit_query_repo, "log", qry); |
98 | html_attr(url); |
97 | html_attr(url); |
|