author | Lars Hjemli <hjemli@gmail.com> | 2007-05-15 22:26:23 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-05-15 22:26:23 (UTC) |
commit | a2ddc10479ec463708e422ca5ce7ec02c22a7d02 (patch) (unidiff) | |
tree | e099ad98a79d61eb6e368a7e7972700f0e65b9ae | |
parent | b28b105ec172b258ae5d629381a5890697c2f938 (diff) | |
download | cgit-a2ddc10479ec463708e422ca5ce7ec02c22a7d02.zip cgit-a2ddc10479ec463708e422ca5ce7ec02c22a7d02.tar.gz cgit-a2ddc10479ec463708e422ca5ce7ec02c22a7d02.tar.bz2 |
Change commit-view to expect h parameter, not id
The change makes the commit-page benefit from repo.defbranch.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | ui-commit.c | 2 | ||||
-rw-r--r-- | ui-log.c | 3 | ||||
-rw-r--r-- | ui-summary.c | 16 |
4 files changed, 13 insertions, 10 deletions
@@ -107,25 +107,25 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
107 | return; | 107 | return; |
108 | } | 108 | } |
109 | 109 | ||
110 | cgit_print_pageheader(cgit_query_page, show_search); | 110 | cgit_print_pageheader(cgit_query_page, show_search); |
111 | 111 | ||
112 | if (!strcmp(cgit_query_page, "log")) { | 112 | if (!strcmp(cgit_query_page, "log")) { |
113 | cgit_print_log(cgit_query_head, cgit_query_ofs, | 113 | cgit_print_log(cgit_query_head, cgit_query_ofs, |
114 | cgit_max_commit_count, cgit_query_search, | 114 | cgit_max_commit_count, cgit_query_search, |
115 | cgit_query_path); | 115 | cgit_query_path); |
116 | } else if (!strcmp(cgit_query_page, "tree")) { | 116 | } else if (!strcmp(cgit_query_page, "tree")) { |
117 | cgit_print_tree(cgit_query_head, cgit_query_sha1, cgit_query_path); | 117 | cgit_print_tree(cgit_query_head, cgit_query_sha1, cgit_query_path); |
118 | } else if (!strcmp(cgit_query_page, "commit")) { | 118 | } else if (!strcmp(cgit_query_page, "commit")) { |
119 | cgit_print_commit(cgit_query_sha1); | 119 | cgit_print_commit(cgit_query_head); |
120 | } else if (!strcmp(cgit_query_page, "view")) { | 120 | } else if (!strcmp(cgit_query_page, "view")) { |
121 | cgit_print_view(cgit_query_sha1, cgit_query_path); | 121 | cgit_print_view(cgit_query_sha1, cgit_query_path); |
122 | } else if (!strcmp(cgit_query_page, "diff")) { | 122 | } else if (!strcmp(cgit_query_page, "diff")) { |
123 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); | 123 | cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); |
124 | } else { | 124 | } else { |
125 | cgit_print_error("Invalid request"); | 125 | cgit_print_error("Invalid request"); |
126 | } | 126 | } |
127 | cgit_print_docend(); | 127 | cgit_print_docend(); |
128 | } | 128 | } |
129 | 129 | ||
130 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) | 130 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) |
131 | { | 131 | { |
diff --git a/ui-commit.c b/ui-commit.c index 8011dfc..93eb8fd 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -188,25 +188,25 @@ void cgit_print_commit(const char *hex) | |||
188 | htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1)); | 188 | htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1)); |
189 | for (p = commit->parents; p ; p = p->next) { | 189 | for (p = commit->parents; p ; p = p->next) { |
190 | parent = lookup_commit_reference(p->item->object.sha1); | 190 | parent = lookup_commit_reference(p->item->object.sha1); |
191 | if (!parent) { | 191 | if (!parent) { |
192 | html("<tr><td colspan='3'>"); | 192 | html("<tr><td colspan='3'>"); |
193 | cgit_print_error("Error reading parent commit"); | 193 | cgit_print_error("Error reading parent commit"); |
194 | html("</td></tr>"); | 194 | html("</td></tr>"); |
195 | continue; | 195 | continue; |
196 | } | 196 | } |
197 | html("<tr><th>parent</th>" | 197 | html("<tr><th>parent</th>" |
198 | "<td colspan='2' class='sha1'>" | 198 | "<td colspan='2' class='sha1'>" |
199 | "<a href='"); | 199 | "<a href='"); |
200 | query = fmt("id=%s", sha1_to_hex(p->item->object.sha1)); | 200 | query = fmt("h=%s", sha1_to_hex(p->item->object.sha1)); |
201 | html_attr(cgit_pageurl(cgit_query_repo, "commit", query)); | 201 | html_attr(cgit_pageurl(cgit_query_repo, "commit", query)); |
202 | htmlf("'>%s</a> (<a href='", | 202 | htmlf("'>%s</a> (<a href='", |
203 | sha1_to_hex(p->item->object.sha1)); | 203 | sha1_to_hex(p->item->object.sha1)); |
204 | query = fmt("id=%s&id2=%s", sha1_to_hex(parent->tree->object.sha1), | 204 | query = fmt("id=%s&id2=%s", sha1_to_hex(parent->tree->object.sha1), |
205 | sha1_to_hex(commit->tree->object.sha1)); | 205 | sha1_to_hex(commit->tree->object.sha1)); |
206 | html_attr(cgit_pageurl(cgit_query_repo, "diff", query)); | 206 | html_attr(cgit_pageurl(cgit_query_repo, "diff", query)); |
207 | html("'>diff</a>)</td></tr>"); | 207 | html("'>diff</a>)</td></tr>"); |
208 | } | 208 | } |
209 | if (cgit_repo->snapshots) { | 209 | if (cgit_repo->snapshots) { |
210 | htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='"); | 210 | htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='"); |
211 | filename = fmt("%s-%s.zip", cgit_query_repo, hex); | 211 | filename = fmt("%s-%s.zip", cgit_query_repo, hex); |
212 | html_attr(cgit_pageurl(cgit_query_repo, "snapshot", | 212 | html_attr(cgit_pageurl(cgit_query_repo, "snapshot", |
@@ -25,25 +25,25 @@ void inspect_files(struct diff_filepair *pair) | |||
25 | void print_commit(struct commit *commit) | 25 | void print_commit(struct commit *commit) |
26 | { | 26 | { |
27 | char buf[32]; | 27 | char buf[32]; |
28 | struct commitinfo *info; | 28 | struct commitinfo *info; |
29 | struct tm *time; | 29 | struct tm *time; |
30 | 30 | ||
31 | info = cgit_parse_commit(commit); | 31 | info = cgit_parse_commit(commit); |
32 | time = gmtime(&commit->date); | 32 | time = gmtime(&commit->date); |
33 | html("<tr><td>"); | 33 | html("<tr><td>"); |
34 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M", time); | 34 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M", time); |
35 | html_txt(buf); | 35 | html_txt(buf); |
36 | html("</td><td>"); | 36 | html("</td><td>"); |
37 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); | 37 | char *qry = fmt("h=%s", sha1_to_hex(commit->object.sha1)); |
38 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); | 38 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); |
39 | html_link_open(url, NULL, NULL); | 39 | html_link_open(url, NULL, NULL); |
40 | html_ntxt(cgit_max_msg_len, info->subject); | 40 | html_ntxt(cgit_max_msg_len, info->subject); |
41 | html_link_close(); | 41 | html_link_close(); |
42 | files = 0; | 42 | files = 0; |
43 | lines = 0; | 43 | lines = 0; |
44 | cgit_diff_commit(commit, inspect_files); | 44 | cgit_diff_commit(commit, inspect_files); |
45 | html("</td><td class='right'>"); | 45 | html("</td><td class='right'>"); |
46 | htmlf("%d", files); | 46 | htmlf("%d", files); |
47 | html("</td><td class='right'>"); | 47 | html("</td><td class='right'>"); |
48 | htmlf("%d", lines); | 48 | htmlf("%d", lines); |
49 | html("</td><td>"); | 49 | html("</td><td>"); |
@@ -112,13 +112,12 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path) | |||
112 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); | 112 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); |
113 | html("'>[prev]</a> "); | 113 | html("'>[prev]</a> "); |
114 | } | 114 | } |
115 | 115 | ||
116 | if ((commit = get_revision(&rev)) != NULL) { | 116 | if ((commit = get_revision(&rev)) != NULL) { |
117 | html(" <a href='"); | 117 | html(" <a href='"); |
118 | html(cgit_pageurl(cgit_query_repo, "log", | 118 | html(cgit_pageurl(cgit_query_repo, "log", |
119 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); | 119 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); |
120 | html("'>[next]</a> "); | 120 | html("'>[next]</a> "); |
121 | } | 121 | } |
122 | html("</div>"); | 122 | html("</div>"); |
123 | } | 123 | } |
124 | |||
diff --git a/ui-summary.c b/ui-summary.c index b99ea98..e7158cc 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -24,54 +24,58 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | |||
24 | html("<tr><td>"); | 24 | html("<tr><td>"); |
25 | url = cgit_pageurl(cgit_query_repo, "log", | 25 | url = cgit_pageurl(cgit_query_repo, "log", |
26 | fmt("h=%s", refname)); | 26 | fmt("h=%s", refname)); |
27 | html_link_open(url, NULL, NULL); | 27 | html_link_open(url, NULL, NULL); |
28 | html_txt(buf); | 28 | html_txt(buf); |
29 | html_link_close(); | 29 | html_link_close(); |
30 | html("</td><td>"); | 30 | html("</td><td>"); |
31 | cgit_print_date(commit->date); | 31 | cgit_print_date(commit->date); |
32 | html("</td><td>"); | 32 | html("</td><td>"); |
33 | html_txt(info->author); | 33 | html_txt(info->author); |
34 | html("</td><td>"); | 34 | html("</td><td>"); |
35 | url = cgit_pageurl(cgit_query_repo, "commit", | 35 | url = cgit_pageurl(cgit_query_repo, "commit", |
36 | fmt("id=%s", sha1_to_hex(sha1))); | 36 | fmt("h=%s", sha1_to_hex(sha1))); |
37 | html_link_open(url, NULL, NULL); | 37 | html_link_open(url, NULL, NULL); |
38 | html_ntxt(cgit_max_msg_len, info->subject); | 38 | html_ntxt(cgit_max_msg_len, info->subject); |
39 | html_link_close(); | 39 | html_link_close(); |
40 | html("</td></tr>\n"); | 40 | html("</td></tr>\n"); |
41 | cgit_free_commitinfo(info); | 41 | cgit_free_commitinfo(info); |
42 | } else { | 42 | } else { |
43 | html("<tr><td>"); | 43 | html("<tr><td>"); |
44 | html_txt(buf); | 44 | html_txt(buf); |
45 | html("</td><td colspan='3'>"); | 45 | html("</td><td colspan='3'>"); |
46 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); | 46 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); |
47 | html("</td></tr>\n"); | 47 | html("</td></tr>\n"); |
48 | } | 48 | } |
49 | return 0; | 49 | return 0; |
50 | } | 50 | } |
51 | 51 | ||
52 | 52 | ||
53 | static void cgit_print_object_ref(struct object *obj) | 53 | static void cgit_print_object_ref(struct object *obj) |
54 | { | 54 | { |
55 | char *page, *url; | 55 | char *page, *arg, *url; |
56 | 56 | ||
57 | if (obj->type == OBJ_COMMIT) | 57 | if (obj->type == OBJ_COMMIT) { |
58 | page = "commit"; | 58 | page = "commit"; |
59 | else if (obj->type == OBJ_TREE) | 59 | arg = "h"; |
60 | } else if (obj->type == OBJ_TREE) { | ||
60 | page = "tree"; | 61 | page = "tree"; |
61 | else | 62 | arg = "id"; |
63 | } else { | ||
62 | page = "view"; | 64 | page = "view"; |
65 | arg = "id"; | ||
66 | } | ||
63 | 67 | ||
64 | url = cgit_pageurl(cgit_query_repo, page, | 68 | url = cgit_pageurl(cgit_query_repo, page, |
65 | fmt("id=%s", sha1_to_hex(obj->sha1))); | 69 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); |
66 | html_link_open(url, NULL, NULL); | 70 | html_link_open(url, NULL, NULL); |
67 | htmlf("%s %s", typename(obj->type), | 71 | htmlf("%s %s", typename(obj->type), |
68 | sha1_to_hex(obj->sha1)); | 72 | sha1_to_hex(obj->sha1)); |
69 | html_link_close(); | 73 | html_link_close(); |
70 | } | 74 | } |
71 | 75 | ||
72 | static void print_tag_header() | 76 | static void print_tag_header() |
73 | { | 77 | { |
74 | html("<tr class='nohover'><th class='left'>Tag</th>" | 78 | html("<tr class='nohover'><th class='left'>Tag</th>" |
75 | "<th class='left'>Created</th>" | 79 | "<th class='left'>Created</th>" |
76 | "<th class='left'>Author</th>" | 80 | "<th class='left'>Author</th>" |
77 | "<th class='left'>Reference</th></tr>\n"); | 81 | "<th class='left'>Reference</th></tr>\n"); |