diff options
author | Lars Hjemli <hjemli@gmail.com> | 2007-06-17 21:53:02 (JST) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-06-17 21:53:02 (JST) |
commit | 42a7eb9c73457319a3fd5441ff26046fc9b31dad (patch) | |
tree | 4771b955e031005e7c222ef0cbabb719f7cd003a /ui-summary.c | |
parent | 48c487d72daef7e71683a85f775db8d36ab20341 (diff) | |
download | cgit-42a7eb9c73457319a3fd5441ff26046fc9b31dad.zip cgit-42a7eb9c73457319a3fd5441ff26046fc9b31dad.tar.gz |
Add cgit_commit_link() + support for id=sha1 to commit view
This adds a function to generate links to the commit page and extends said
page to use id from querystring as primary revision specified (fallback to
h).
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-summary.c')
-rw-r--r-- | ui-summary.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/ui-summary.c b/ui-summary.c index 29b76e3..03dd078 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -15,8 +15,10 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | |||
15 | { | 15 | { |
16 | struct commit *commit; | 16 | struct commit *commit; |
17 | struct commitinfo *info; | 17 | struct commitinfo *info; |
18 | char buf[256], *url; | 18 | char buf[256]; |
19 | char *ref; | ||
19 | 20 | ||
21 | ref = xstrdup(refname); | ||
20 | strncpy(buf, refname, sizeof(buf)); | 22 | strncpy(buf, refname, sizeof(buf)); |
21 | commit = lookup_commit(sha1); | 23 | commit = lookup_commit(sha1); |
22 | // object is not really parsed at this point, because of some fallout | 24 | // object is not really parsed at this point, because of some fallout |
@@ -25,17 +27,13 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | |||
25 | if (commit && !parse_commit(commit)){ | 27 | if (commit && !parse_commit(commit)){ |
26 | info = cgit_parse_commit(commit); | 28 | info = cgit_parse_commit(commit); |
27 | html("<tr><td>"); | 29 | html("<tr><td>"); |
28 | cgit_log_link(refname, NULL, NULL, refname, NULL, NULL); | 30 | cgit_log_link(ref, NULL, NULL, ref, NULL, NULL); |
29 | html("</td><td>"); | 31 | html("</td><td>"); |
30 | cgit_print_age(commit->date, -1, NULL); | 32 | cgit_print_age(commit->date, -1, NULL); |
31 | html("</td><td>"); | 33 | html("</td><td>"); |
32 | html_txt(info->author); | 34 | html_txt(info->author); |
33 | html("</td><td>"); | 35 | html("</td><td>"); |
34 | url = cgit_pageurl(cgit_query_repo, "commit", | 36 | cgit_commit_link(info->subject, NULL, NULL, ref, NULL); |
35 | fmt("h=%s", sha1_to_hex(sha1))); | ||
36 | html_link_open(url, NULL, NULL); | ||
37 | html_ntxt(cgit_max_msg_len, info->subject); | ||
38 | html_link_close(); | ||
39 | html("</td></tr>\n"); | 37 | html("</td></tr>\n"); |
40 | cgit_free_commitinfo(info); | 38 | cgit_free_commitinfo(info); |
41 | } else { | 39 | } else { |
@@ -45,6 +43,7 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | |||
45 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); | 43 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); |
46 | html("</td></tr>\n"); | 44 | html("</td></tr>\n"); |
47 | } | 45 | } |
46 | free(ref); | ||
48 | return 0; | 47 | return 0; |
49 | } | 48 | } |
50 | 49 | ||
@@ -54,8 +53,9 @@ static void cgit_print_object_ref(struct object *obj) | |||
54 | char *page, *arg, *url; | 53 | char *page, *arg, *url; |
55 | 54 | ||
56 | if (obj->type == OBJ_COMMIT) { | 55 | if (obj->type == OBJ_COMMIT) { |
57 | page = "commit"; | 56 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, |
58 | arg = "h"; | 57 | cgit_query_head, sha1_to_hex(obj->sha1)); |
58 | return; | ||
59 | } else if (obj->type == OBJ_TREE) { | 59 | } else if (obj->type == OBJ_TREE) { |
60 | page = "tree"; | 60 | page = "tree"; |
61 | arg = "id"; | 61 | arg = "id"; |