author | Lars Hjemli <hjemli@gmail.com> | 2007-10-27 08:06:03 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-10-27 08:53:27 (UTC) |
commit | f6310fec783d2721ef61815a0eec525d6a904452 (patch) (unidiff) | |
tree | 04882b1a89dcbaaaec17ceca8a5210f92dd6f920 /ui-summary.c | |
parent | fe211c7eef6c7d3e39486d6a7484d3b4debff88f (diff) | |
download | cgit-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>
-rw-r--r-- | ui-summary.c | 21 |
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 | |||
@@ -1,61 +1,66 @@ | |||
1 | /* ui-summary.c: functions for generating repo summary page | 1 | /* ui-summary.c: functions for generating repo summary page |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | static int header; | 11 | static int header; |
12 | 12 | ||
13 | static int cmp_tag_age(void *a, void *b) | 13 | static int cmp_age(int age1, int age2) |
14 | { | 14 | { |
15 | struct refinfo *r1 = *(struct refinfo **)a; | 15 | if (age1 != 0 && age2 != 0) |
16 | struct refinfo *r2 = *(struct refinfo **)b; | 16 | return age2 - age1; |
17 | |||
18 | if (r1->tag->tagger_date != 0 && r2->tag->tagger_date != 0) | ||
19 | return r2->tag->tagger_date - r1->tag->tagger_date; | ||
20 | 17 | ||
21 | if (r1->tag->tagger_date == 0 && r2->tag->tagger_date == 0) | 18 | if (age1 == 0 && age2 == 0) |
22 | return 0; | 19 | return 0; |
23 | 20 | ||
24 | if (r1 == 0) | 21 | if (age1 == 0) |
25 | return +1; | 22 | return +1; |
26 | 23 | ||
27 | return -1; | 24 | return -1; |
28 | } | 25 | } |
29 | 26 | ||
27 | static int cmp_tag_age(const void *a, const void *b) | ||
28 | { | ||
29 | struct refinfo *r1 = *(struct refinfo **)a; | ||
30 | struct refinfo *r2 = *(struct refinfo **)b; | ||
31 | |||
32 | return cmp_age(r1->tag->tagger_date, r2->tag->tagger_date); | ||
33 | } | ||
34 | |||
30 | static void cgit_print_branch(struct refinfo *ref) | 35 | static void cgit_print_branch(struct refinfo *ref) |
31 | { | 36 | { |
32 | struct commit *commit; | 37 | struct commit *commit; |
33 | struct commitinfo *info; | 38 | struct commitinfo *info; |
34 | char *name = (char *)ref->refname; | 39 | char *name = (char *)ref->refname; |
35 | 40 | ||
36 | commit = lookup_commit(ref->object->sha1); | 41 | commit = lookup_commit(ref->object->sha1); |
37 | // object is not really parsed at this point, because of some fallout | 42 | // object is not really parsed at this point, because of some fallout |
38 | // from previous calls to git functions in cgit_print_log() | 43 | // from previous calls to git functions in cgit_print_log() |
39 | commit->object.parsed = 0; | 44 | commit->object.parsed = 0; |
40 | if (commit && !parse_commit(commit)){ | 45 | if (commit && !parse_commit(commit)){ |
41 | info = cgit_parse_commit(commit); | 46 | info = cgit_parse_commit(commit); |
42 | html("<tr><td>"); | 47 | html("<tr><td>"); |
43 | cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0); | 48 | cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0); |
44 | html("</td><td>"); | 49 | html("</td><td>"); |
45 | cgit_print_age(commit->date, -1, NULL); | 50 | cgit_print_age(commit->date, -1, NULL); |
46 | html("</td><td>"); | 51 | html("</td><td>"); |
47 | html_txt(info->author); | 52 | html_txt(info->author); |
48 | html("</td><td>"); | 53 | html("</td><td>"); |
49 | cgit_commit_link(info->subject, NULL, NULL, name, NULL); | 54 | cgit_commit_link(info->subject, NULL, NULL, name, NULL); |
50 | html("</td></tr>\n"); | 55 | html("</td></tr>\n"); |
51 | cgit_free_commitinfo(info); | 56 | cgit_free_commitinfo(info); |
52 | } else { | 57 | } else { |
53 | html("<tr><td>"); | 58 | html("<tr><td>"); |
54 | html_txt(name); | 59 | html_txt(name); |
55 | html("</td><td colspan='3'>"); | 60 | html("</td><td colspan='3'>"); |
56 | htmlf("*** bad ref %s ***", sha1_to_hex(ref->object->sha1)); | 61 | htmlf("*** bad ref %s ***", sha1_to_hex(ref->object->sha1)); |
57 | html("</td></tr>\n"); | 62 | html("</td></tr>\n"); |
58 | } | 63 | } |
59 | } | 64 | } |
60 | 65 | ||
61 | static void print_tag_header() | 66 | static void print_tag_header() |