-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | shared.c | 3 | ||||
-rw-r--r-- | ui-summary.c | 31 |
3 files changed, 32 insertions, 3 deletions
@@ -146,2 +146,3 @@ extern int cgit_summary_log; | |||
146 | extern int cgit_summary_tags; | 146 | extern int cgit_summary_tags; |
147 | extern int cgit_summary_branches; | ||
147 | 148 | ||
@@ -41,2 +41,3 @@ int cgit_summary_log = 0; | |||
41 | int cgit_summary_tags = 0; | 41 | int cgit_summary_tags = 0; |
42 | int cgit_summary_branches = 0; | ||
42 | int cgit_renamelimit = -1; | 43 | int cgit_renamelimit = -1; |
@@ -184,2 +185,4 @@ void cgit_global_config_cb(const char *name, const char *value) | |||
184 | cgit_summary_log = atoi(value); | 185 | cgit_summary_log = atoi(value); |
186 | else if (!strcmp(name, "summary-branches")) | ||
187 | cgit_summary_branches = atoi(value); | ||
185 | else if (!strcmp(name, "summary-tags")) | 188 | else if (!strcmp(name, "summary-tags")) |
diff --git a/ui-summary.c b/ui-summary.c index 05170cc..df79d01 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -26,2 +26,18 @@ static int cmp_age(int age1, int age2) | |||
26 | 26 | ||
27 | static int cmp_ref_name(const void *a, const void *b) | ||
28 | { | ||
29 | struct refinfo *r1 = *(struct refinfo **)a; | ||
30 | struct refinfo *r2 = *(struct refinfo **)b; | ||
31 | |||
32 | return strcmp(r1->refname, r2->refname); | ||
33 | } | ||
34 | |||
35 | static int cmp_branch_age(const void *a, const void *b) | ||
36 | { | ||
37 | struct refinfo *r1 = *(struct refinfo **)a; | ||
38 | struct refinfo *r2 = *(struct refinfo **)b; | ||
39 | |||
40 | return cmp_age(r1->commit->committer_date, r2->commit->committer_date); | ||
41 | } | ||
42 | |||
27 | static int cmp_tag_age(const void *a, const void *b) | 43 | static int cmp_tag_age(const void *a, const void *b) |
@@ -152,3 +168,3 @@ static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1, | |||
152 | 168 | ||
153 | static void cgit_print_branches() | 169 | static void cgit_print_branches(int maxcount) |
154 | { | 170 | { |
@@ -165,3 +181,12 @@ static void cgit_print_branches() | |||
165 | for_each_branch_ref(cgit_refs_cb, &list); | 181 | for_each_branch_ref(cgit_refs_cb, &list); |
166 | for(i=0; i<list.count; i++) | 182 | |
183 | if (maxcount == 0 || maxcount > list.count) | ||
184 | maxcount = list.count; | ||
185 | |||
186 | if (maxcount < list.count) { | ||
187 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); | ||
188 | qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); | ||
189 | } | ||
190 | |||
191 | for(i=0; i<maxcount; i++) | ||
167 | cgit_print_branch(list.refs[i]); | 192 | cgit_print_branch(list.refs[i]); |
@@ -215,3 +240,3 @@ void cgit_print_summary() | |||
215 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 240 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |
216 | cgit_print_branches(); | 241 | cgit_print_branches(cgit_summary_branches); |
217 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); | 242 | html("<tr class='nohover'><td colspan='4'> </td></tr>"); |