]> git.cameronkatri.com Git - cgit.git/commitdiff
Move logic for age comparision from cmp_tag_age into cmp_age()
authorLars Hjemli <hjemli@gmail.com>
Sat, 27 Oct 2007 08:06:03 +0000 (10:06 +0200)
committerLars Hjemli <hjemli@gmail.com>
Sat, 27 Oct 2007 08:53:27 +0000 (10:53 +0200)
Simple refactoring to enable later filtering of branches based on age.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
ui-summary.c

index 3d5eda84f1261841606fe12f1430495c77f31b55..05170cc9fd50e51ced8d74a03193019a0b44ba98 100644 (file)
 
 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;