From 763a6a09deec7290365a0072d25630daa7b417e2 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 27 Oct 2007 10:13:42 +0200 Subject: Add support for config param summary-branches This parameter can be used to specify max number of branches to show on the summary page (if not all branches will be displayed, the "most idle" branches are the ones to be pruned). The default value for this parameter is 0, which disables the pruning. Signed-off-by: Lars Hjemli --- ui-summary.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'ui-summary.c') diff --git a/ui-summary.c b/ui-summary.c index 05170cc..df79d01 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -24,6 +24,22 @@ static int cmp_age(int age1, int age2) return -1; } +static int cmp_ref_name(const void *a, const void *b) +{ + struct refinfo *r1 = *(struct refinfo **)a; + struct refinfo *r2 = *(struct refinfo **)b; + + return strcmp(r1->refname, r2->refname); +} + +static int cmp_branch_age(const void *a, const void *b) +{ + struct refinfo *r1 = *(struct refinfo **)a; + struct refinfo *r2 = *(struct refinfo **)b; + + return cmp_age(r1->commit->committer_date, r2->commit->committer_date); +} + static int cmp_tag_age(const void *a, const void *b) { struct refinfo *r1 = *(struct refinfo **)a; @@ -150,7 +166,7 @@ static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, return 0; } -static void cgit_print_branches() +static void cgit_print_branches(int maxcount) { struct reflist list; int i; @@ -163,7 +179,16 @@ static void cgit_print_branches() list.refs = NULL; list.alloc = list.count = 0; for_each_branch_ref(cgit_refs_cb, &list); - for(i=0; i list.count) + maxcount = list.count; + + if (maxcount < list.count) { + qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); + qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); + } + + for(i=0; i"); if (cgit_summary_log > 0) html(" "); - cgit_print_branches(); + cgit_print_branches(cgit_summary_branches); html(" "); cgit_print_tags(cgit_summary_tags); html(""); -- cgit v1.2.3-59-g8ed1b