summaryrefslogtreecommitdiffabout
path: root/ui-summary.c
authorLars Hjemli <hjemli@gmail.com>2007-10-27 11:34:17 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-10-27 11:34:17 (UTC)
commitb4d4a25aa481aa3ac8ad69df4dfa53eaa5de6173 (patch) (unidiff)
treeeac36573ba5ed7965d2b83f931a493aaef96307c /ui-summary.c
parentdd0f27eb36e737261b57d6ebcbd9fe20e559470d (diff)
downloadcgit-b4d4a25aa481aa3ac8ad69df4dfa53eaa5de6173.zip
cgit-b4d4a25aa481aa3ac8ad69df4dfa53eaa5de6173.tar.gz
cgit-b4d4a25aa481aa3ac8ad69df4dfa53eaa5de6173.tar.bz2
Cleanup code introduced by the filter-refs topic
The functions used to print branches and tags were only half-done and somewhat confused. Fix it. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-summary.c') (more/less context) (show whitespace changes)
-rw-r--r--ui-summary.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/ui-summary.c b/ui-summary.c
index 016fea2..178e959 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -48,35 +48,23 @@ static int cmp_tag_age(const void *a, const void *b)
48 return cmp_age(r1->tag->tagger_date, r2->tag->tagger_date); 48 return cmp_age(r1->tag->tagger_date, r2->tag->tagger_date);
49} 49}
50 50
51static void cgit_print_branch(struct refinfo *ref) 51static int print_branch(struct refinfo *ref)
52{ 52{
53 struct commit *commit; 53 struct commitinfo *info = ref->commit;
54 struct commitinfo *info;
55 char *name = (char *)ref->refname; 54 char *name = (char *)ref->refname;
56 55
57 commit = lookup_commit(ref->object->sha1); 56 if (!info)
58 // object is not really parsed at this point, because of some fallout 57 return 1;
59 // from previous calls to git functions in cgit_print_log()
60 commit->object.parsed = 0;
61 if (commit && !parse_commit(commit)){
62 info = cgit_parse_commit(commit);
63 html("<tr><td>"); 58 html("<tr><td>");
64 cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0); 59 cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0);
65 html("</td><td>"); 60 html("</td><td>");
66 cgit_print_age(commit->date, -1, NULL); 61 cgit_print_age(info->commit->date, -1, NULL);
67 html("</td><td>"); 62 html("</td><td>");
68 html_txt(info->author); 63 html_txt(info->author);
69 html("</td><td>"); 64 html("</td><td>");
70 cgit_commit_link(info->subject, NULL, NULL, name, NULL); 65 cgit_commit_link(info->subject, NULL, NULL, name, NULL);
71 html("</td></tr>\n"); 66 html("</td></tr>\n");
72 cgit_free_commitinfo(info); 67 return 0;
73 } else {
74 html("<tr><td>");
75 html_txt(name);
76 html("</td><td colspan='3'>");
77 htmlf("*** bad ref %s ***", sha1_to_hex(ref->object->sha1));
78 html("</td></tr>\n");
79 }
80} 68}
81 69
82static void print_tag_header() 70static void print_tag_header()
@@ -95,9 +83,10 @@ static int print_tag(struct refinfo *ref)
95 char *url, *name = (char *)ref->refname; 83 char *url, *name = (char *)ref->refname;
96 84
97 if (ref->object->type == OBJ_TAG) { 85 if (ref->object->type == OBJ_TAG) {
98 tag = lookup_tag(ref->object->sha1); 86 tag = (struct tag *)ref->object;
99 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) 87 info = ref->tag;
100 return 2; 88 if (!tag || !info)
89 return 1;
101 html("<tr><td>"); 90 html("<tr><td>");
102 url = cgit_pageurl(cgit_query_repo, "tag", 91 url = cgit_pageurl(cgit_query_repo, "tag",
103 fmt("id=%s", name)); 92 fmt("id=%s", name));
@@ -196,7 +185,7 @@ void cgit_print_branches(int maxcount)
196 } 185 }
197 186
198 for(i=0; i<maxcount; i++) 187 for(i=0; i<maxcount; i++)
199 cgit_print_branch(list.refs[i]); 188 print_branch(list.refs[i]);
200 189
201 if (maxcount < list.count) 190 if (maxcount < list.count)
202 print_refs_link("heads"); 191 print_refs_link("heads");