[PATCH 1/3] Added "sort-sections" flag for the repository listing

Tobias Bieniek Tobias.Bieniek at gmx.de
Mon Jul 2 17:38:56 CEST 2012


Flag which, when set to "1", will make sort the sections on the
repository listing by name. Set this flag to "0" if the order in the
cgitrc file should be preserved. Default value: "1".
---
 cgit.c        |    3 +++
 cgit.h        |    1 +
 cgitrc.5.txt  |    5 +++++
 ui-repolist.c |    2 +-
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/cgit.c b/cgit.c
index b9b3a66..4ec00f6 100644
--- a/cgit.c
+++ b/cgit.c
@@ -229,6 +229,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, "sort-sections"))
+		ctx.cfg.sort_sections = atoi(value);
 	else if (!strcmp(name, "source-filter"))
 		ctx.cfg.source_filter = new_filter(value, SOURCE);
 	else if (!strcmp(name, "summary-log"))
@@ -355,6 +357,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.sort_sections = 1;
 	ctx->cfg.summary_branches = 10;
 	ctx->cfg.summary_log = 10;
 	ctx->cfg.summary_tags = 10;
diff --git a/cgit.h b/cgit.h
index 6ee6769..86afad1 100644
--- a/cgit.h
+++ b/cgit.h
@@ -224,6 +224,7 @@ struct cgit_config {
 	int scan_hidden_path;
 	int section_from_path;
 	int snapshots;
+	int sort_sections;
 	int summary_branches;
 	int summary_log;
 	int summary_tags;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index a72241f..3e2d87f 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -336,6 +336,11 @@ snapshots::
 	values "tar", "tar.gz", "tar.bz2", "tar.xz" and "zip". Default value:
 	none.
 
+sort-sections::
+	Flag which, when set to "1", will make sort the sections on the
+	repository listing by name. Set this flag to "0" if the order in the
+	cgitrc file should be preserved. Default value: "1".
+
 source-filter::
 	Specifies a command which will be invoked to format plaintext blobs
 	in the tree view. The command will get the blob content on its STDIN
diff --git a/ui-repolist.c b/ui-repolist.c
index d946f32..4cf3ec1 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -237,7 +237,7 @@ void cgit_print_repolist()
 
 	if(ctx.qry.sort)
 		sorted = sort_repolist(ctx.qry.sort);
-	else
+	else if (ctx.cfg.sort_sections)
 		sort_repolist("section");
 
 	html("<table summary='repository list' class='list nowrap'>");
-- 
1.7.10





More information about the CGit mailing list