diff options
1 files changed, 46 insertions, 0 deletions
| -rw-r--r-- | ui-refs.c | 46 |
@@ -179,6 +179,52 @@ void cgit_print_branches(int maxcount) cgit_free_reflist_inner(&list); } +void cgit_print_branches_component(int maxcount) +{ + struct reflist list; + int i; + struct commitinfo *info; + char *name; + + html("<tr class='nohover'><th class='left'>Branch</th>" + "<th class='left'>Age</th></tr>\n"); + + list.refs = NULL; + list.alloc = list.count = 0; + refs_for_each_branch_ref(get_main_ref_store(the_repository), + cgit_refs_cb, &list); + if (ctx.repo->enable_remote_branches) + refs_for_each_remote_ref(get_main_ref_store(the_repository), + cgit_refs_cb, &list); + + if (maxcount == 0 || maxcount > list.count) + maxcount = list.count; + + qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); + if (ctx.repo->branch_sort == 0) + qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); + + for (i = 0; i < maxcount; i++) { + info = list.refs[i]->commit; + name = (char *)list.refs[i]->refname; + + if (!info || list.refs[i]->object->type != OBJ_COMMIT) + continue; + + html("<tr><td>"); + cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL, + ctx.qry.showmsg, 0); + html("</td><td>"); + cgit_print_age(info->committer_date, info->committer_tz, -1); + html("</td></tr>\n"); + } + + if (maxcount < list.count) + print_refs_link("heads"); + + cgit_free_reflist_inner(&list); +} + void cgit_print_tags(int maxcount) { struct reflist list; |
