From 87c47488d02fcace4da0d468cd9ddd1651b7949e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 30 Mar 2017 13:19:50 +0200 Subject: ui-repolist: properly sort by age When empty repos exist, comparing them against an existing repo with a good mtime might, with particular qsort implementations, not sort correctly, because of this brokenness: if (get_repo_modtime(r1, &t) && get_repo_modtime(r2, &t)) However, sorting by the age column works as expected, so anyway, to tidy things up, we simply reuse that function. Signed-off-by: Jason A. Donenfeld --- ui-repolist.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'ui-repolist.c') diff --git a/ui-repolist.c b/ui-repolist.c index b57ea60..20a4f56 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -184,27 +184,6 @@ static int cmp(const char *s1, const char *s2) return 0; } -static int sort_section(const void *a, const void *b) -{ - const struct cgit_repo *r1 = a; - const struct cgit_repo *r2 = b; - int result; - time_t t; - - result = cmp(r1->section, r2->section); - if (!result) { - if (!strcmp(ctx.cfg.repository_sort, "age")) { - // get_repo_modtime caches the value in r->mtime, so we don't - // have to worry about inefficiencies here. - if (get_repo_modtime(r1, &t) && get_repo_modtime(r2, &t)) - result = r2->mtime - r1->mtime; - } - if (!result) - result = cmp(r1->name, r2->name); - } - return result; -} - static int sort_name(const void *a, const void *b) { const struct cgit_repo *r1 = a; @@ -241,6 +220,23 @@ static int sort_idle(const void *a, const void *b) return t2 - t1; } +static int sort_section(const void *a, const void *b) +{ + const struct cgit_repo *r1 = a; + const struct cgit_repo *r2 = b; + int result; + time_t t; + + result = cmp(r1->section, r2->section); + if (!result) { + if (!strcmp(ctx.cfg.repository_sort, "age")) + result = sort_idle(r1, r2); + if (!result) + result = cmp(r1->name, r2->name); + } + return result; +} + struct sortcolumn { const char *name; int (*fn)(const void *a, const void *b); -- cgit v1.2.3-24-g4f1b From 7ebdb30fdf91d1f63b4fb07e54b089136de5507b Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 5 Apr 2017 06:38:27 +0200 Subject: Remove unused variable from sort_section() Signed-off-by: Lukas Fleischer --- ui-repolist.c | 1 - 1 file changed, 1 deletion(-) (limited to 'ui-repolist.c') diff --git a/ui-repolist.c b/ui-repolist.c index 20a4f56..7272e87 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -225,7 +225,6 @@ static int sort_section(const void *a, const void *b) const struct cgit_repo *r1 = a; const struct cgit_repo *r2 = b; int result; - time_t t; result = cmp(r1->section, r2->section); if (!result) { -- cgit v1.2.3-24-g4f1b From 70787254b270b1505aa8427813f64131be5df86c Mon Sep 17 00:00:00 2001 From: Jeff Smith Date: Sun, 1 Oct 2017 23:39:05 -0500 Subject: html: html_ntxt with no ellipsis For implementing a ui-blame page, there is need for a function that outputs a selection from a block of text, transformed for HTML output, but with no further modifications or additions. Signed-off-by: Jeff Smith Reviewed-by: John Keeping --- ui-repolist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ui-repolist.c') diff --git a/ui-repolist.c b/ui-repolist.c index 7272e87..af52f9b 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -329,7 +329,8 @@ void cgit_print_repolist(void) repourl = cgit_repourl(ctx.repo->url); html_link_open(repourl, NULL, NULL); free(repourl); - html_ntxt(ctx.cfg.max_repodesc_len, ctx.repo->desc); + if (html_ntxt(ctx.repo->desc, ctx.cfg.max_repodesc_len) < 0) + html("..."); html_link_close(); html(""); if (ctx.cfg.enable_index_owner) { -- cgit v1.2.3-24-g4f1b