about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cgit.c6
-rw-r--r--cgit.h2
-rw-r--r--cgitrc.5.txt12
-rw-r--r--ui-repolist.c22
4 files changed, 37 insertions, 5 deletions
diff --git a/cgit.c b/cgit.c
index 4656ed6..24ef8e0 100644
--- a/cgit.c
+++ b/cgit.c
@@ -199,6 +199,8 @@ void config_cb(const char *name, const char *value)
 		ctx.cfg.cache_static_ttl = atoi(value);
 	else if (!strcmp(name, "cache-dynamic-ttl"))
 		ctx.cfg.cache_dynamic_ttl = atoi(value);
+	else if (!strcmp(name, "case-sensitive-sort"))
+		ctx.cfg.case_sensitive_sort = atoi(value);
 	else if (!strcmp(name, "about-filter"))
 		ctx.cfg.about_filter = new_filter(value, ABOUT);
 	else if (!strcmp(name, "commit-filter"))
@@ -231,6 +233,8 @@ void config_cb(const char *name, const char *value)
 		ctx.cfg.scan_hidden_path = atoi(value);
 	else if (!strcmp(name, "section-from-path"))
 		ctx.cfg.section_from_path = atoi(value);
+	else if (!strcmp(name, "section-sort"))
+		ctx.cfg.section_sort = xstrdup(value);
 	else if (!strcmp(name, "source-filter"))
 		ctx.cfg.source_filter = new_filter(value, SOURCE);
 	else if (!strcmp(name, "summary-log"))
@@ -335,6 +339,7 @@ static void prepare_context(struct cgit_context *ctx)
 	ctx->cfg.cache_root_ttl = 5;
 	ctx->cfg.cache_scanrc_ttl = 15;
 	ctx->cfg.cache_static_ttl = -1;
+	ctx->cfg.case_sensitive_sort = 1;
 	ctx->cfg.css = "/cgit.css";
 	ctx->cfg.logo = "/cgit.png";
 	ctx->cfg.local_time = 0;
@@ -359,6 +364,7 @@ static void prepare_context(struct cgit_context *ctx)
 	ctx->cfg.scan_hidden_path = 0;
 	ctx->cfg.script_name = CGIT_SCRIPT_NAME;
 	ctx->cfg.section = "";
+	ctx->cfg.section_sort = "name";
 	ctx->cfg.summary_branches = 10;
 	ctx->cfg.summary_log = 10;
 	ctx->cfg.summary_tags = 10;
diff --git a/cgit.h b/cgit.h
index 91b4d72..79ba7ad 100644
--- a/cgit.h
+++ b/cgit.h
@@ -187,6 +187,7 @@ struct cgit_config {
 	char *root_readme;
 	char *script_name;
 	char *section;
+	char *section_sort;
 	char *virtual_root;
 	char *strict_export;
 	int cache_size;
@@ -196,6 +197,7 @@ struct cgit_config {
 	int cache_root_ttl;
 	int cache_scanrc_ttl;
 	int cache_static_ttl;
+	int case_sensitive_sort;
 	int embedded;
 	int enable_filter_overrides;
 	int enable_gitweb_owner;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index d1a90c5..902fff3 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -70,6 +70,10 @@ cache-static-ttl::
 	version of repository pages accessed with a fixed SHA1. Default value:
 	"5".
 
+case-sensitive-sort::
+	Sort items in the repo list case sensitively. Default value: "1".
+	See also: section-sort.
+
 clone-prefix::
 	Space-separated list of common prefixes which, when combined with a
 	repository url, generates valid clone urls for the repository. This
@@ -333,11 +337,17 @@ section::
 	after this option will inherit the current section name. Default value:
 	none.
 
+section-sort::
+	The way in which repositories in each section are sorted. Valid values
+	are "name" for sorting by the repo name or "age" for sorting by the
+	most recently updated repository. Default value: "name". See also:
+	section, case-sensitive-sort.
+
 section-from-path::
 	A number which, if specified before scan-path, specifies how many
 	path elements from each repo path to use as a default section name.
 	If negative, cgit will discard the specified number of path elements
-	above the repo directory. Default value: 0.
+	above the repo directory. Default value: "0".
 
 side-by-side-diffs::
 	If set to "1" shows side-by-side diffs instead of unidiffs per
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 @@
 #include "cgit.h"
 #include "html.h"
 #include "ui-shared.h"
+#include <strings.h>
 
 time_t read_agefile(char *path)
 {
@@ -131,8 +132,12 @@ void print_pager(int items, int pagelen, char *search, char *sort)
 
 static int cmp(const char *s1, const char *s2)
 {
-	if (s1 && s2)
-		return strcmp(s1, s2);
+	if (s1 && s2) {
+		if (ctx.cfg.case_sensitive_sort)
+			return strcmp(s1, s2);
+		else
+			return strcasecmp(s1, s2);
+	}
 	if (s1 && !s2)
 		return -1;
 	if (s2 && !s1)
@@ -145,10 +150,19 @@ 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)
-		result = cmp(r1->name, r2->name);
+	if (!result) {
+		if (!strcmp(ctx.cfg.section_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;
 }
 
-compat-util.h). Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13configfile.c: don't include system headers directlyJohn Keeping git-compat-util.h may define various values that affect the interpretation of system headers. In most places we include cgit.h first, which pulls in git-compat-util.h, but this file does not depend on anything else in CGit, so use git-compat-util.h directly. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13Remove redundant includesJohn Keeping These are all included in git-compat-util.h (when necessary), which we include in cgit.h. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13Makefile: include Git's config.mak.unameJohn Keeping This pulls in the correct value of $(INSTALL) on a wide variety of systems. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13tests: allow shell to be overriddenJohn Keeping On some systems (e.g. Solaris), /bin/sh is not a POSIX shell. Git already provides suitable overrides in its config.mak.uname file and we provide cgit.conf to allow the user to further change this. The code for this is taken from Git's t/Makefile, meaning that we now invoke the tests in the same way that Git does. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13redirect: cleanlinessJason A. Donenfeld 2015-08-13redirect: be more careful for different cgi setupsJason A. Donenfeld 2015-08-12ui-log: fix double countingJohn Keeping This crept in while rebasing the previous commit onto an updated upstream. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-12log: allow users to follow a fileJohn Keeping Teach the "log" UI to behave in the same way as "git log --follow", when given a suitable instruction by the user. The default behaviour remains to show the log without following renames, but the follow behaviour can be activated by following a link in the page header. Follow is not the default because outputting merges in follow mode is tricky ("git log --follow" will not show merges). We also disable the graph in follow mode because the commit graph is not simplified so we end up with frequent gaps in the graph and many lines that do not connect with any commits we're actually showing. We also teach the "diff" and "commit" UIs to respect the follow flag on URLs, causing the single-file version of these UIs to detect renames. This feature is needed only for commits that rename the path we're interested in. For commits before the file has been renamed (i.e. that appear later in the log list) we change the file path in the links from the log to point to the old name; this means that links to commits always limit by the path known to that commit. If we didn't do this we would need to walk down the log diff'ing every commit whenever we want to show a commit. The drawback is that the "Log" link in the top bar of such a page links to the log limited by the old name, so it will only show pre-rename commits. I consider this a reasonable trade-off since the "Back" button still works and the log matches the path displayed in the top bar. Since following renames requires running diff on every commit we consider, I've added a knob to the configuration file to globally enable/disable this feature. Note that we may consider a large number of commits the revision walking machinery no longer performs any path limitation so we have to examine every commit until we find a page full of commits that affect the target path or something related to it. Suggested-by: René Neumann <necoro@necoro.eu> Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-12shared: make cgit_diff_tree_cb publicJohn Keeping This will allow us to use this nice wrapper function elsewhere, avoiding dealing with the diff queue when we only need to inspect a filepair. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-12t0110: Chain together using &&Jason A. Donenfeld 2015-08-12about: always ensure page has a trailing slashJason A. Donenfeld Otherwise we can't easily embed links to other /about/ pages. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2015-08-12filters: apply HTML escapingLazaros Koromilas http://www.w3.org/International/questions/qa-escapes#use 2015-08-12git: update to v2.5.0Christian Hesse Update to git version v2.5.0. * Upstream commit 5455ee0573a22bb793a7083d593ae1ace909cd4c (Merge branch 'bc/object-id') changed API: for_each_ref() callback functions were taught to name the objects not with "unsigned char sha1[20]" but with "struct object_id". * Upstream commit dcf692625ac569fefbe52269061230f4fde10e47 (path.c: make get_pathname() call sites return const char *) Signed-off-by: Christian Hesse <mail@eworm.de> 2015-08-12Fix processing of repo.hide and repo.ignoreDaniel Reichelt