author | Lars Hjemli <hjemli@gmail.com> | 2008-11-29 13:27:35 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-11-29 13:27:35 (UTC) |
commit | 54272e60965ec6a98b49cbf67d72a4b1f5adc55b (patch) (unidiff) | |
tree | 183bc1876d0c53b879627bb9fd66f2978d41929e | |
parent | f250c1ca2ea7f35d65f639e42e8b8f0657515e5d (diff) | |
download | cgit-54272e60965ec6a98b49cbf67d72a4b1f5adc55b.zip cgit-54272e60965ec6a98b49cbf67d72a4b1f5adc55b.tar.gz cgit-54272e60965ec6a98b49cbf67d72a4b1f5adc55b.tar.bz2 |
ui-repolist: sort null values last
When sorting on e.g. owner, it's not interesting to get all repos
without owner at the top of the list.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-repolist.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ui-repolist.c b/ui-repolist.c index 0de328b..cf27cb3 100644 --- a/ui-repolist.c +++ b/ui-repolist.c | |||
@@ -87,67 +87,67 @@ void print_sort_header(const char *title, const char *sort) | |||
87 | } | 87 | } |
88 | htmlf("'>%s</a></th>", title); | 88 | htmlf("'>%s</a></th>", title); |
89 | } | 89 | } |
90 | 90 | ||
91 | void print_header(int columns) | 91 | void print_header(int columns) |
92 | { | 92 | { |
93 | html("<tr class='nohover'>"); | 93 | html("<tr class='nohover'>"); |
94 | print_sort_header("Name", "name"); | 94 | print_sort_header("Name", "name"); |
95 | print_sort_header("Description", "desc"); | 95 | print_sort_header("Description", "desc"); |
96 | print_sort_header("Owner", "owner"); | 96 | print_sort_header("Owner", "owner"); |
97 | print_sort_header("Idle", "idle"); | 97 | print_sort_header("Idle", "idle"); |
98 | if (ctx.cfg.enable_index_links) | 98 | if (ctx.cfg.enable_index_links) |
99 | html("<th class='left'>Links</th>"); | 99 | html("<th class='left'>Links</th>"); |
100 | html("</tr>\n"); | 100 | html("</tr>\n"); |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | void print_pager(int items, int pagelen, char *search) | 104 | void print_pager(int items, int pagelen, char *search) |
105 | { | 105 | { |
106 | int i; | 106 | int i; |
107 | html("<div class='pager'>"); | 107 | html("<div class='pager'>"); |
108 | for(i = 0; i * pagelen < items; i++) | 108 | for(i = 0; i * pagelen < items; i++) |
109 | cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), NULL, | 109 | cgit_index_link(fmt("[%d]", i+1), fmt("Page %d", i+1), NULL, |
110 | search, i * pagelen); | 110 | search, i * pagelen); |
111 | html("</div>"); | 111 | html("</div>"); |
112 | } | 112 | } |
113 | 113 | ||
114 | static int cmp(const char *s1, const char *s2) | 114 | static int cmp(const char *s1, const char *s2) |
115 | { | 115 | { |
116 | if (s1 && s2) | 116 | if (s1 && s2) |
117 | return strcmp(s1, s2); | 117 | return strcmp(s1, s2); |
118 | if (s1 && !s2) | 118 | if (s1 && !s2) |
119 | return 1; | ||
120 | if (s2 && !s1) | ||
121 | return -1; | 119 | return -1; |
120 | if (s2 && !s1) | ||
121 | return 1; | ||
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | 124 | ||
125 | static int sort_name(const void *a, const void *b) | 125 | static int sort_name(const void *a, const void *b) |
126 | { | 126 | { |
127 | const struct cgit_repo *r1 = a; | 127 | const struct cgit_repo *r1 = a; |
128 | const struct cgit_repo *r2 = b; | 128 | const struct cgit_repo *r2 = b; |
129 | 129 | ||
130 | return cmp(r1->name, r2->name); | 130 | return cmp(r1->name, r2->name); |
131 | } | 131 | } |
132 | 132 | ||
133 | static int sort_desc(const void *a, const void *b) | 133 | static int sort_desc(const void *a, const void *b) |
134 | { | 134 | { |
135 | const struct cgit_repo *r1 = a; | 135 | const struct cgit_repo *r1 = a; |
136 | const struct cgit_repo *r2 = b; | 136 | const struct cgit_repo *r2 = b; |
137 | 137 | ||
138 | return cmp(r1->desc, r2->desc); | 138 | return cmp(r1->desc, r2->desc); |
139 | } | 139 | } |
140 | 140 | ||
141 | static int sort_owner(const void *a, const void *b) | 141 | static int sort_owner(const void *a, const void *b) |
142 | { | 142 | { |
143 | const struct cgit_repo *r1 = a; | 143 | const struct cgit_repo *r1 = a; |
144 | const struct cgit_repo *r2 = b; | 144 | const struct cgit_repo *r2 = b; |
145 | 145 | ||
146 | return cmp(r1->owner, r2->owner); | 146 | return cmp(r1->owner, r2->owner); |
147 | } | 147 | } |
148 | 148 | ||
149 | static int sort_idle(const void *a, const void *b) | 149 | static int sort_idle(const void *a, const void *b) |
150 | { | 150 | { |
151 | const struct cgit_repo *r1 = a; | 151 | const struct cgit_repo *r1 = a; |
152 | const struct cgit_repo *r2 = b; | 152 | const struct cgit_repo *r2 = b; |
153 | time_t t1, t2; | 153 | time_t t1, t2; |