summaryrefslogtreecommitdiffabout
path: root/ui-summary.c
authorLars Hjemli <hjemli@gmail.com>2007-10-25 08:13:25 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-10-27 07:34:15 (UTC)
commit0c1ebce2042e69569d99551d7749b97b4e579609 (patch) (unidiff)
treea0bcb407541d4c11017d78380866600096d39c22 /ui-summary.c
parente397ff7024293223f48f235fcf072fc526cae7af (diff)
downloadcgit-0c1ebce2042e69569d99551d7749b97b4e579609.zip
cgit-0c1ebce2042e69569d99551d7749b97b4e579609.tar.gz
cgit-0c1ebce2042e69569d99551d7749b97b4e579609.tar.bz2
Use reflist to print branch info
This updates ui-summary.c to use a reflist instead of for_each_branch_ref(), as a step towards more flexible branch handling (filtering/sorting). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-summary.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-summary.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/ui-summary.c b/ui-summary.c
index de8a180..1e895a6 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -12,4 +12,3 @@ static int header;
12 12
13static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1, 13static void cgit_print_branch(struct refinfo *ref)
14 int flags, void *cb_data)
15{ 14{
@@ -17,8 +16,5 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
17 struct commitinfo *info; 16 struct commitinfo *info;
18 char buf[256]; 17 char *name = (char *)ref->refname;
19 char *ref;
20 18
21 ref = xstrdup(refname); 19 commit = lookup_commit(ref->object->sha1);
22 strncpy(buf, refname, sizeof(buf));
23 commit = lookup_commit(sha1);
24 // object is not really parsed at this point, because of some fallout 20 // object is not really parsed at this point, because of some fallout
@@ -29,3 +25,3 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
29 html("<tr><td>"); 25 html("<tr><td>");
30 cgit_log_link(ref, NULL, NULL, ref, NULL, NULL, 0); 26 cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0);
31 html("</td><td>"); 27 html("</td><td>");
@@ -35,3 +31,3 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
35 html("</td><td>"); 31 html("</td><td>");
36 cgit_commit_link(info->subject, NULL, NULL, ref, NULL); 32 cgit_commit_link(info->subject, NULL, NULL, name, NULL);
37 html("</td></tr>\n"); 33 html("</td></tr>\n");
@@ -40,9 +36,7 @@ static int cgit_print_branch_cb(const char *refname, const unsigned char *sha1,
40 html("<tr><td>"); 36 html("<tr><td>");
41 html_txt(buf); 37 html_txt(name);
42 html("</td><td colspan='3'>"); 38 html("</td><td colspan='3'>");
43 htmlf("*** bad ref %s ***", sha1_to_hex(sha1)); 39 htmlf("*** bad ref %s ***", sha1_to_hex(ref->object->sha1));
44 html("</td></tr>\n"); 40 html("</td></tr>\n");
45 } 41 }
46 free(ref);
47 return 0;
48} 42}
@@ -146,2 +140,5 @@ static void cgit_print_branches()
146{ 140{
141 struct reflist list;
142 int i;
143
147 html("<tr class='nohover'><th class='left'>Branch</th>" 144 html("<tr class='nohover'><th class='left'>Branch</th>"
@@ -150,3 +147,8 @@ static void cgit_print_branches()
150 "<th class='left'>Head commit</th></tr>\n"); 147 "<th class='left'>Head commit</th></tr>\n");
151 for_each_branch_ref(cgit_print_branch_cb, NULL); 148
149 list.refs = NULL;
150 list.alloc = list.count = 0;
151 for_each_branch_ref(cgit_refs_cb, &list);
152 for(i=0; i<list.count; i++)
153 cgit_print_branch(list.refs[i]);
152} 154}