summaryrefslogtreecommitdiffabout
path: root/ui-summary.c
authorLars Hjemli <hjemli@gmail.com>2007-10-27 08:06:03 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-10-27 08:53:27 (UTC)
commitf6310fec783d2721ef61815a0eec525d6a904452 (patch) (side-by-side diff)
tree04882b1a89dcbaaaec17ceca8a5210f92dd6f920 /ui-summary.c
parentfe211c7eef6c7d3e39486d6a7484d3b4debff88f (diff)
downloadcgit-f6310fec783d2721ef61815a0eec525d6a904452.zip
cgit-f6310fec783d2721ef61815a0eec525d6a904452.tar.gz
cgit-f6310fec783d2721ef61815a0eec525d6a904452.tar.bz2
Move logic for age comparision from cmp_tag_age into cmp_age()
Simple refactoring to enable later filtering of branches based on age. 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.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/ui-summary.c b/ui-summary.c
index 3d5eda8..05170cc 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -9,25 +9,30 @@
#include "cgit.h"
static int header;
-static int cmp_tag_age(void *a, void *b)
+static int cmp_age(int age1, int age2)
{
- struct refinfo *r1 = *(struct refinfo **)a;
- struct refinfo *r2 = *(struct refinfo **)b;
-
- if (r1->tag->tagger_date != 0 && r2->tag->tagger_date != 0)
- return r2->tag->tagger_date - r1->tag->tagger_date;
+ if (age1 != 0 && age2 != 0)
+ return age2 - age1;
- if (r1->tag->tagger_date == 0 && r2->tag->tagger_date == 0)
+ if (age1 == 0 && age2 == 0)
return 0;
- if (r1 == 0)
+ if (age1 == 0)
return +1;
return -1;
}
+static int cmp_tag_age(const void *a, const void *b)
+{
+ struct refinfo *r1 = *(struct refinfo **)a;
+ struct refinfo *r2 = *(struct refinfo **)b;
+
+ return cmp_age(r1->tag->tagger_date, r2->tag->tagger_date);
+}
+
static void cgit_print_branch(struct refinfo *ref)
{
struct commit *commit;
struct commitinfo *info;