diff options
-rw-r--r-- | cgit.c | 5 | ||||
-rw-r--r-- | cgit.css | 5 | ||||
-rw-r--r-- | cgit.h | 4 | ||||
-rw-r--r-- | ui-commit.c | 3 | ||||
-rw-r--r-- | ui-log.c | 8 | ||||
-rw-r--r-- | ui-tree.c | 25 |
6 files changed, 37 insertions, 13 deletions
@@ -108,9 +108,10 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
108 | 108 | ||
109 | if (!strcmp(cgit_query_page, "log")) { | 109 | if (!strcmp(cgit_query_page, "log")) { |
110 | cgit_print_log(cgit_query_head, cgit_query_ofs, | 110 | cgit_print_log(cgit_query_head, cgit_query_ofs, |
111 | cgit_max_commit_count, cgit_query_search); | 111 | cgit_max_commit_count, cgit_query_search, |
112 | cgit_query_path); | ||
112 | } else if (!strcmp(cgit_query_page, "tree")) { | 113 | } else if (!strcmp(cgit_query_page, "tree")) { |
113 | cgit_print_tree(cgit_query_sha1, cgit_query_path); | 114 | cgit_print_tree(cgit_query_head, cgit_query_sha1, cgit_query_path); |
114 | } else if (!strcmp(cgit_query_page, "commit")) { | 115 | } else if (!strcmp(cgit_query_page, "commit")) { |
115 | cgit_print_commit(cgit_query_sha1); | 116 | cgit_print_commit(cgit_query_sha1); |
116 | } else if (!strcmp(cgit_query_page, "view")) { | 117 | } else if (!strcmp(cgit_query_page, "view")) { |
@@ -189,6 +189,11 @@ td.filesize { | |||
189 | font-family: monospace; | 189 | font-family: monospace; |
190 | } | 190 | } |
191 | 191 | ||
192 | td.links { | ||
193 | font-size: 80%; | ||
194 | padding-left: 2em; | ||
195 | } | ||
196 | |||
192 | td.filemode { | 197 | td.filemode { |
193 | font-family: monospace; | 198 | font-family: monospace; |
194 | } | 199 | } |
@@ -169,10 +169,10 @@ extern void cgit_print_snapshot_start(const char *mimetype, | |||
169 | 169 | ||
170 | extern void cgit_print_repolist(struct cacheitem *item); | 170 | extern void cgit_print_repolist(struct cacheitem *item); |
171 | extern void cgit_print_summary(); | 171 | extern void cgit_print_summary(); |
172 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep); | 172 | extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path); |
173 | extern void cgit_print_view(const char *hex, char *path); | 173 | extern void cgit_print_view(const char *hex, char *path); |
174 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); | 174 | extern void cgit_print_blob(struct cacheitem *item, const char *hex, char *path); |
175 | extern void cgit_print_tree(const char *hex, char *path); | 175 | extern void cgit_print_tree(const char *rev, const char *hex, char *path); |
176 | extern void cgit_print_commit(const char *hex); | 176 | extern void cgit_print_commit(const char *hex); |
177 | extern void cgit_print_diff(const char *old_hex, const char *new_hex, char *path); | 177 | extern void cgit_print_diff(const char *old_hex, const char *new_hex, char *path); |
178 | extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, | 178 | extern void cgit_print_snapshot(struct cacheitem *item, const char *hex, |
diff --git a/ui-commit.c b/ui-commit.c index b3d1c28..20a7cb2 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -186,7 +186,8 @@ void cgit_print_commit(const char *hex) | |||
186 | cgit_print_date(info->committer_date); | 186 | cgit_print_date(info->committer_date); |
187 | html("</td></tr>\n"); | 187 | html("</td></tr>\n"); |
188 | html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='"); | 188 | html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='"); |
189 | query = fmt("id=%s", sha1_to_hex(commit->tree->object.sha1)); | 189 | query = fmt("h=%s&id=%s", sha1_to_hex(commit->object.sha1), |
190 | sha1_to_hex(commit->tree->object.sha1)); | ||
190 | html_attr(cgit_pageurl(cgit_query_repo, "tree", query)); | 191 | html_attr(cgit_pageurl(cgit_query_repo, "tree", query)); |
191 | htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1)); | 192 | htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1)); |
192 | for (p = commit->parents; p ; p = p->next) { | 193 | for (p = commit->parents; p ; p = p->next) { |
@@ -53,16 +53,20 @@ void print_commit(struct commit *commit) | |||
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep) | 56 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path) |
57 | { | 57 | { |
58 | struct rev_info rev; | 58 | struct rev_info rev; |
59 | struct commit *commit; | 59 | struct commit *commit; |
60 | const char *argv[3] = {NULL, tip, NULL}; | 60 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
61 | int argc = 2; | 61 | int argc = 2; |
62 | int i; | 62 | int i; |
63 | 63 | ||
64 | if (grep) | 64 | if (grep) |
65 | argv[argc++] = fmt("--grep=%s", grep); | 65 | argv[argc++] = fmt("--grep=%s", grep); |
66 | if (path) { | ||
67 | argv[argc++] = "--"; | ||
68 | argv[argc++] = path; | ||
69 | } | ||
66 | init_revisions(&rev, NULL); | 70 | init_revisions(&rev, NULL); |
67 | rev.abbrev = DEFAULT_ABBREV; | 71 | rev.abbrev = DEFAULT_ABBREV; |
68 | rev.commit_format = CMIT_FMT_DEFAULT; | 72 | rev.commit_format = CMIT_FMT_DEFAULT; |
@@ -8,9 +8,10 @@ | |||
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | char *curr_rev; | ||
11 | 12 | ||
12 | static int print_entry(const unsigned char *sha1, const char *base, | 13 | static int print_entry(const unsigned char *sha1, const char *base, |
13 | int baselen, const char *pathname, unsigned int mode, | 14 | int baselen, const char *pathname, unsigned int mode, |
14 | int stage) | 15 | int stage) |
15 | { | 16 | { |
16 | char *name; | 17 | char *name; |
@@ -35,30 +36,41 @@ static int print_entry(const unsigned char *sha1, const char *base, | |||
35 | sha1_to_hex(sha1))); | 36 | sha1_to_hex(sha1))); |
36 | } else if (S_ISDIR(mode)) { | 37 | } else if (S_ISDIR(mode)) { |
37 | html("class='ls-dir'><a href='"); | 38 | html("class='ls-dir'><a href='"); |
38 | html_attr(cgit_pageurl(cgit_query_repo, "tree", | 39 | html_attr(cgit_pageurl(cgit_query_repo, "tree", |
39 | fmt("id=%s&path=%s%s/", | 40 | fmt("h=%s&id=%s&path=%s%s/", |
41 | curr_rev, | ||
40 | sha1_to_hex(sha1), | 42 | sha1_to_hex(sha1), |
41 | cgit_query_path ? cgit_query_path : "", | 43 | cgit_query_path ? cgit_query_path : "", |
42 | pathname))); | 44 | pathname))); |
43 | } else { | 45 | } else { |
44 | html("class='ls-blob'><a href='"); | 46 | html("class='ls-blob'><a href='"); |
45 | html_attr(cgit_pageurl(cgit_query_repo, "view", | 47 | html_attr(cgit_pageurl(cgit_query_repo, "view", |
46 | fmt("id=%s&path=%s%s", sha1_to_hex(sha1), | 48 | fmt("h=%s&id=%s&path=%s%s", curr_rev, |
49 | sha1_to_hex(sha1), | ||
47 | cgit_query_path ? cgit_query_path : "", | 50 | cgit_query_path ? cgit_query_path : "", |
48 | pathname))); | 51 | pathname))); |
49 | } | 52 | } |
50 | htmlf("'>%s</a></div></td>", name); | 53 | htmlf("'>%s</a></div></td>", name); |
51 | htmlf("<td class='filesize'>%li</td>", size); | 54 | htmlf("<td class='filesize'>%li</td>", size); |
55 | |||
56 | html("<td class='links'><a href='"); | ||
57 | html_attr(cgit_pageurl(cgit_query_repo, "log", | ||
58 | fmt("h=%s&path=%s%s", | ||
59 | curr_rev, | ||
60 | cgit_query_path ? cgit_query_path : "", | ||
61 | pathname))); | ||
62 | html("'>history</a></td>"); | ||
52 | html("</tr>\n"); | 63 | html("</tr>\n"); |
53 | free(name); | 64 | free(name); |
54 | return 0; | 65 | return 0; |
55 | } | 66 | } |
56 | 67 | ||
57 | void cgit_print_tree(const char *hex, char *path) | 68 | void cgit_print_tree(const char *rev, const char *hex, char *path) |
58 | { | 69 | { |
59 | struct tree *tree; | 70 | struct tree *tree; |
60 | unsigned char sha1[20]; | 71 | unsigned char sha1[20]; |
61 | 72 | ||
73 | curr_rev = xstrdup(rev); | ||
62 | if (get_sha1_hex(hex, sha1)) { | 74 | if (get_sha1_hex(hex, sha1)) { |
63 | cgit_print_error(fmt("Invalid object id: %s", hex)); | 75 | cgit_print_error(fmt("Invalid object id: %s", hex)); |
64 | return; | 76 | return; |
@@ -75,6 +87,7 @@ void cgit_print_tree(const char *hex, char *path) | |||
75 | html("<th class='left'>Mode</th>"); | 87 | html("<th class='left'>Mode</th>"); |
76 | html("<th class='left'>Name</th>"); | 88 | html("<th class='left'>Name</th>"); |
77 | html("<th class='right'>Size</th>"); | 89 | html("<th class='right'>Size</th>"); |
90 | html("<th/>"); | ||
78 | html("</tr>\n"); | 91 | html("</tr>\n"); |
79 | read_tree_recursive(tree, "", 0, 1, NULL, print_entry); | 92 | read_tree_recursive(tree, "", 0, 1, NULL, print_entry); |
80 | html("</table>\n"); | 93 | html("</table>\n"); |