author | Lars Hjemli <hjemli@gmail.com> | 2007-10-25 18:33:04 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-10-27 08:53:19 (UTC) |
commit | ef1cc6ef941cedf2e34fa1ed34ca8cd8a0cfdacc (patch) (unidiff) | |
tree | 5c9d40e556a5787e9338bc506dec37360f54d8f5 /ui-summary.c | |
parent | 502d71072a813e6fadb2e59fb47c2782b542674a (diff) | |
download | cgit-ef1cc6ef941cedf2e34fa1ed34ca8cd8a0cfdacc.zip cgit-ef1cc6ef941cedf2e34fa1ed34ca8cd8a0cfdacc.tar.gz cgit-ef1cc6ef941cedf2e34fa1ed34ca8cd8a0cfdacc.tar.bz2 |
Sort tags by age
This adds a function to compare timestamps and then uses it as callback
for qsort() before printing out tags.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-summary.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ui-summary.c b/ui-summary.c index c684628..43582da 100644 --- a/ui-summary.c +++ b/ui-summary.c | |||
@@ -12,2 +12,19 @@ static int header; | |||
12 | 12 | ||
13 | static int cmp_tag_age(void *a, void *b) | ||
14 | { | ||
15 | struct refinfo *r1 = *(struct refinfo **)a; | ||
16 | struct refinfo *r2 = *(struct refinfo **)b; | ||
17 | |||
18 | if (r1->tag->tagger_date != 0 && r2->tag->tagger_date != 0) | ||
19 | return r2->tag->tagger_date - r1->tag->tagger_date; | ||
20 | |||
21 | if (r1->tag->tagger_date == 0 && r2->tag->tagger_date == 0) | ||
22 | return 0; | ||
23 | |||
24 | if (r1 == 0) | ||
25 | return +1; | ||
26 | |||
27 | return -1; | ||
28 | } | ||
29 | |||
13 | static void cgit_print_branch(struct refinfo *ref) | 30 | static void cgit_print_branch(struct refinfo *ref) |
@@ -158,2 +175,3 @@ static void cgit_print_tags() | |||
158 | return; | 175 | return; |
176 | qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); | ||
159 | print_tag_header(); | 177 | print_tag_header(); |