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) (side-by-side diff) | |
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
@@ -103,33 +103,33 @@ static void cgit_print_repo_page(struct cacheitem *item) if (!cgit_query_page) { cgit_print_pageheader("summary", show_search); cgit_print_summary(); cgit_print_docend(); return; } cgit_print_pageheader(cgit_query_page, show_search); if (!strcmp(cgit_query_page, "log")) { cgit_print_log(cgit_query_head, cgit_query_ofs, cgit_max_commit_count, cgit_query_search, cgit_query_path); } else if (!strcmp(cgit_query_page, "tree")) { cgit_print_tree(cgit_query_head, cgit_query_sha1, cgit_query_path); } else if (!strcmp(cgit_query_page, "commit")) { - cgit_print_commit(cgit_query_sha1); + cgit_print_commit(cgit_query_head); } else if (!strcmp(cgit_query_page, "view")) { cgit_print_view(cgit_query_sha1, cgit_query_path); } else if (!strcmp(cgit_query_page, "diff")) { cgit_print_diff(cgit_query_sha1, cgit_query_sha2, cgit_query_path); } else { cgit_print_error("Invalid request"); } cgit_print_docend(); } static void cgit_fill_cache(struct cacheitem *item, int use_cache) { static char buf[PATH_MAX]; int stdout2; getcwd(buf, sizeof(buf)); diff --git a/ui-commit.c b/ui-commit.c index 8011dfc..93eb8fd 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -184,33 +184,33 @@ void cgit_print_commit(const char *hex) html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='"); query = fmt("h=%s&id=%s", sha1_to_hex(commit->object.sha1), sha1_to_hex(commit->tree->object.sha1)); html_attr(cgit_pageurl(cgit_query_repo, "tree", query)); htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1)); for (p = commit->parents; p ; p = p->next) { parent = lookup_commit_reference(p->item->object.sha1); if (!parent) { html("<tr><td colspan='3'>"); cgit_print_error("Error reading parent commit"); html("</td></tr>"); continue; } html("<tr><th>parent</th>" "<td colspan='2' class='sha1'>" "<a href='"); - query = fmt("id=%s", sha1_to_hex(p->item->object.sha1)); + query = fmt("h=%s", sha1_to_hex(p->item->object.sha1)); html_attr(cgit_pageurl(cgit_query_repo, "commit", query)); htmlf("'>%s</a> (<a href='", sha1_to_hex(p->item->object.sha1)); query = fmt("id=%s&id2=%s", sha1_to_hex(parent->tree->object.sha1), sha1_to_hex(commit->tree->object.sha1)); html_attr(cgit_pageurl(cgit_query_repo, "diff", query)); html("'>diff</a>)</td></tr>"); } if (cgit_repo->snapshots) { htmlf("<tr><th>download</th><td colspan='2' class='sha1'><a href='"); filename = fmt("%s-%s.zip", cgit_query_repo, hex); html_attr(cgit_pageurl(cgit_query_repo, "snapshot", fmt("id=%s&name=%s", hex, filename))); htmlf("'>%s</a></td></tr>", filename); } html("</table>\n"); @@ -21,33 +21,33 @@ void inspect_files(struct diff_filepair *pair) files++; cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); } void print_commit(struct commit *commit) { char buf[32]; struct commitinfo *info; struct tm *time; info = cgit_parse_commit(commit); time = gmtime(&commit->date); html("<tr><td>"); strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M", time); html_txt(buf); html("</td><td>"); - char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); + char *qry = fmt("h=%s", sha1_to_hex(commit->object.sha1)); char *url = cgit_pageurl(cgit_query_repo, "commit", qry); html_link_open(url, NULL, NULL); html_ntxt(cgit_max_msg_len, info->subject); html_link_close(); files = 0; lines = 0; cgit_diff_commit(commit, inspect_files); html("</td><td class='right'>"); htmlf("%d", files); html("</td><td class='right'>"); htmlf("%d", lines); html("</td><td>"); html_txt(info->author); html("</td></tr>\n"); cgit_free_commitinfo(info); } @@ -108,17 +108,16 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *path) html("<div class='pager'>"); if (ofs > 0) { html(" <a href='"); html(cgit_pageurl(cgit_query_repo, cgit_query_page, fmt("h=%s&ofs=%d", tip, ofs-cnt))); html("'>[prev]</a> "); } if ((commit = get_revision(&rev)) != NULL) { html(" <a href='"); html(cgit_pageurl(cgit_query_repo, "log", fmt("h=%s&ofs=%d", tip, ofs+cnt))); html("'>[next]</a> "); } html("</div>"); } - diff --git a/ui-summary.c b/ui-summary.c index b99ea98..e7158cc 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -20,62 +20,66 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, strncpy(buf, refname, sizeof(buf)); commit = lookup_commit(sha1); if (commit && !parse_commit(commit)){ info = cgit_parse_commit(commit); html("<tr><td>"); url = cgit_pageurl(cgit_query_repo, "log", fmt("h=%s", refname)); html_link_open(url, NULL, NULL); html_txt(buf); html_link_close(); html("</td><td>"); cgit_print_date(commit->date); html("</td><td>"); html_txt(info->author); html("</td><td>"); url = cgit_pageurl(cgit_query_repo, "commit", - fmt("id=%s", sha1_to_hex(sha1))); + fmt("h=%s", sha1_to_hex(sha1))); html_link_open(url, NULL, NULL); html_ntxt(cgit_max_msg_len, info->subject); html_link_close(); html("</td></tr>\n"); cgit_free_commitinfo(info); } else { html("<tr><td>"); html_txt(buf); html("</td><td colspan='3'>"); htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); html("</td></tr>\n"); } return 0; } static void cgit_print_object_ref(struct object *obj) { - char *page, *url; + char *page, *arg, *url; - if (obj->type == OBJ_COMMIT) + if (obj->type == OBJ_COMMIT) { page = "commit"; - else if (obj->type == OBJ_TREE) + arg = "h"; + } else if (obj->type == OBJ_TREE) { page = "tree"; - else + arg = "id"; + } else { page = "view"; + arg = "id"; + } url = cgit_pageurl(cgit_query_repo, page, - fmt("id=%s", sha1_to_hex(obj->sha1))); + fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); html_link_open(url, NULL, NULL); htmlf("%s %s", typename(obj->type), sha1_to_hex(obj->sha1)); html_link_close(); } static void print_tag_header() { html("<tr class='nohover'><th class='left'>Tag</th>" "<th class='left'>Created</th>" "<th class='left'>Author</th>" "<th class='left'>Reference</th></tr>\n"); header = 1; } static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, |