diff options
Diffstat (limited to 'ui-summary.c')
-rw-r--r-- | ui-summary.c | 49 |
1 files changed, 10 insertions, 39 deletions
diff --git a/ui-summary.c b/ui-summary.c index 4bda4c2..de8a180 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,21 +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 | url = cgit_pageurl(cgit_query_repo, "log", | 30 | cgit_log_link(ref, NULL, NULL, ref, NULL, NULL, 0); |
29 | fmt("h=%s", refname)); | ||
30 | html_link_open(url, NULL, NULL); | ||
31 | html_txt(buf); | ||
32 | html_link_close(); | ||
33 | html("</td><td>"); | 31 | html("</td><td>"); |
34 | cgit_print_age(commit->date, -1, NULL); | 32 | cgit_print_age(commit->date, -1, NULL); |
35 | html("</td><td>"); | 33 | html("</td><td>"); |
36 | html_txt(info->author); | 34 | html_txt(info->author); |
37 | html("</td><td>"); | 35 | html("</td><td>"); |
38 | url = cgit_pageurl(cgit_query_repo, "commit", | 36 | cgit_commit_link(info->subject, NULL, NULL, ref, NULL); |
39 | fmt("h=%s", sha1_to_hex(sha1))); | ||
40 | html_link_open(url, NULL, NULL); | ||
41 | html_ntxt(cgit_max_msg_len, info->subject); | ||
42 | html_link_close(); | ||
43 | html("</td></tr>\n"); | 37 | html("</td></tr>\n"); |
44 | cgit_free_commitinfo(info); | 38 | cgit_free_commitinfo(info); |
45 | } else { | 39 | } else { |
@@ -49,33 +43,10 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, | |||
49 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); | 43 | htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); |
50 | html("</td></tr>\n"); | 44 | html("</td></tr>\n"); |
51 | } | 45 | } |
46 | free(ref); | ||
52 | return 0; | 47 | return 0; |
53 | } | 48 | } |
54 | 49 | ||
55 | |||
56 | static void cgit_print_object_ref(struct object *obj) | ||
57 | { | ||
58 | char *page, *arg, *url; | ||
59 | |||
60 | if (obj->type == OBJ_COMMIT) { | ||
61 | page = "commit"; | ||
62 | arg = "h"; | ||
63 | } else if (obj->type == OBJ_TREE) { | ||
64 | page = "tree"; | ||
65 | arg = "id"; | ||
66 | } else { | ||
67 | page = "view"; | ||
68 | arg = "id"; | ||
69 | } | ||
70 | |||
71 | url = cgit_pageurl(cgit_query_repo, page, | ||
72 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); | ||
73 | html_link_open(url, NULL, NULL); | ||
74 | htmlf("%s %s", typename(obj->type), | ||
75 | sha1_to_hex(obj->sha1)); | ||
76 | html_link_close(); | ||
77 | } | ||
78 | |||
79 | static void print_tag_header() | 50 | static void print_tag_header() |
80 | { | 51 | { |
81 | html("<tr class='nohover'><th class='left'>Tag</th>" | 52 | html("<tr class='nohover'><th class='left'>Tag</th>" |
@@ -104,8 +75,8 @@ static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, | |||
104 | if (!header) | 75 | if (!header) |
105 | print_tag_header(); | 76 | print_tag_header(); |
106 | html("<tr><td>"); | 77 | html("<tr><td>"); |
107 | url = cgit_pageurl(cgit_query_repo, "view", | 78 | url = cgit_pageurl(cgit_query_repo, "tag", |
108 | fmt("id=%s", sha1_to_hex(sha1))); | 79 | fmt("id=%s", refname)); |
109 | html_link_open(url, NULL, NULL); | 80 | html_link_open(url, NULL, NULL); |
110 | html_txt(buf); | 81 | html_txt(buf); |
111 | html_link_close(); | 82 | html_link_close(); |
@@ -116,7 +87,7 @@ static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, | |||
116 | if (info->tagger) | 87 | if (info->tagger) |
117 | html(info->tagger); | 88 | html(info->tagger); |
118 | html("</td><td>"); | 89 | html("</td><td>"); |
119 | cgit_print_object_ref(tag->tagged); | 90 | cgit_object_link(tag->tagged); |
120 | html("</td></tr>\n"); | 91 | html("</td></tr>\n"); |
121 | } else { | 92 | } else { |
122 | if (!header) | 93 | if (!header) |
@@ -124,7 +95,7 @@ static int cgit_print_tag_cb(const char *refname, const unsigned char *sha1, | |||
124 | html("<tr><td>"); | 95 | html("<tr><td>"); |
125 | html_txt(buf); | 96 | html_txt(buf); |
126 | html("</td><td colspan='2'/><td>"); | 97 | html("</td><td colspan='2'/><td>"); |
127 | cgit_print_object_ref(obj); | 98 | cgit_object_link(obj); |
128 | html("</td></tr>\n"); | 99 | html("</td></tr>\n"); |
129 | } | 100 | } |
130 | return 0; | 101 | return 0; |