diff options
Diffstat (limited to 'ui-repolist.c')
| -rw-r--r-- | ui-repolist.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/ui-repolist.c b/ui-repolist.c index d946f32..4e2bdf4 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "cgit.h" | 9 | #include "cgit.h" |
| 10 | #include "html.h" | 10 | #include "html.h" |
| 11 | #include "ui-shared.h" | 11 | #include "ui-shared.h" |
| 12 | #include <strings.h> | ||
| 12 | 13 | ||
| 13 | time_t read_agefile(char *path) | 14 | time_t read_agefile(char *path) |
| 14 | { | 15 | { |
| @@ -131,8 +132,12 @@ void print_pager(int items, int pagelen, char *search, char *sort) | |||
| 131 | 132 | ||
| 132 | static int cmp(const char *s1, const char *s2) | 133 | static int cmp(const char *s1, const char *s2) |
| 133 | { | 134 | { |
| 134 | if (s1 && s2) | 135 | if (s1 && s2) { |
| 135 | return strcmp(s1, s2); | 136 | if (ctx.cfg.case_sensitive_sort) |
| 137 | return strcmp(s1, s2); | ||
| 138 | else | ||
| 139 | return strcasecmp(s1, s2); | ||
| 140 | } | ||
| 136 | if (s1 && !s2) | 141 | if (s1 && !s2) |
| 137 | return -1; | 142 | return -1; |
| 138 | if (s2 && !s1) | 143 | if (s2 && !s1) |
| @@ -145,10 +150,19 @@ static int sort_section(const void *a, const void *b) | |||
| 145 | const struct cgit_repo *r1 = a; | 150 | const struct cgit_repo *r1 = a; |
| 146 | const struct cgit_repo *r2 = b; | 151 | const struct cgit_repo *r2 = b; |
| 147 | int result; | 152 | int result; |
| 153 | time_t t; | ||
| 148 | 154 | ||
| 149 | result = cmp(r1->section, r2->section); | 155 | result = cmp(r1->section, r2->section); |
| 150 | if (!result) | 156 | if (!result) { |
| 151 | result = cmp(r1->name, r2->name); | 157 | if (!strcmp(ctx.cfg.section_sort, "age")) { |
| 158 | // get_repo_modtime caches the value in r->mtime, so we don't | ||
| 159 | // have to worry about inefficiencies here. | ||
| 160 | if (get_repo_modtime(r1, &t) && get_repo_modtime(r2, &t)) | ||
| 161 | result = r2->mtime - r1->mtime; | ||
| 162 | } | ||
| 163 | if (!result) | ||
| 164 | result = cmp(r1->name, r2->name); | ||
| 165 | } | ||
| 152 | return result; | 166 | return result; |
| 153 | } | 167 | } |
| 154 | 168 | ||
