all repos — cgit @ 389cc17357e2040c9542d3e085f64a8d2f085e9a

a hyperfast web frontend for git written in c

Add branch-sort and repo.branch-sort options.

When set to "name", branches are sorted by name, which is the current
default. When set to "age", branches are sorted by the age of the
repository.

This feature was requested by Konstantin Ryabitsev for use on
kernel.org.

Proposed-by: Konstantin Ryabitsev <mricon@kernel.org>
Jason A. Donenfeld Jason@zx2c4.com
Mon, 08 Apr 2013 16:57:12 +0200
commit

389cc17357e2040c9542d3e085f64a8d2f085e9a

parent

880223dc845e8b502e753425b889cbb70b73478e

5 files changed, 46 insertions(+), 22 deletions(-)

jump to
M cgit.ccgit.c

@@ -84,7 +84,12 @@ else if (!strcmp(name, "enable-remote-branches"))

repo->enable_remote_branches = atoi(value); else if (!strcmp(name, "enable-subject-links")) repo->enable_subject_links = atoi(value); - else if (!strcmp(name, "commit-sort")) { + else if (!strcmp(name, "branch-sort")) { + if (!strcmp(value, "age")) + repo->branch_sort = 1; + if (!strcmp(value, "name")) + repo->branch_sort = 0; + } else if (!strcmp(name, "commit-sort")) { if (!strcmp(value, "date")) repo->commit_sort = 1; if (!strcmp(value, "topo"))

@@ -271,6 +276,11 @@ if (!strcmp(value, "date"))

ctx.cfg.commit_sort = 1; if (!strcmp(value, "topo")) ctx.cfg.commit_sort = 2; + } else if (!strcmp(name, "branch-sort")) { + if (!strcmp(value, "age")) + ctx.cfg.branch_sort = 1; + if (!strcmp(value, "name")) + ctx.cfg.branch_sort = 0; } else if (!prefixcmp(name, "mimetype.")) add_mimetype(name + 9, value); else if (!strcmp(name, "include"))

@@ -345,6 +355,8 @@ 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.branch_sort = 0; + ctx->cfg.commit_sort = 0; ctx->cfg.css = "/cgit.css"; ctx->cfg.logo = "/cgit.png"; ctx->cfg.local_time = 0;
M cgit.hcgit.h

@@ -85,6 +85,7 @@ int enable_log_linecount;

int enable_remote_branches; int enable_subject_links; int max_stats; + int branch_sort; int commit_sort; time_t mtime; struct cgit_filter *about_filter;

@@ -234,6 +235,7 @@ int summary_branches;

int summary_log; int summary_tags; int ssdiff; + int branch_sort; int commit_sort; struct string_list mimetypes; struct cgit_filter *about_filter;
M cgitrc.5.txtcgitrc.5.txt

@@ -40,6 +40,11 @@ The first line in the file is used as input to the "parse_date"

function in libgit. Recommended timestamp-format is "yyyy-mm-dd hh:mm:ss". Default value: "info/web/last-modified". +branch-sort:: + Flag which, when set to "age", enables date ordering in the branch ref + list, and when set to "name" enables ordering by branch name. Default + value: "name". + cache-root:: Path used to store the cgit cache entries. Default value: "/var/cache/cgit". See also: "MACRO EXPANSION".

@@ -91,6 +96,12 @@ The command will get the message on its STDIN, and the STDOUT from the

command will be included verbatim as the commit message, i.e. this can be used to implement bugtracker integration. Default value: none. See also: "FILTER API". + +commit-sort:: + Flag which, when set to "date", enables strict date ordering in the + commit log, and when set to "topo" enables strict topological + ordering. If unset, the default ordering of "git log" is used. Default + value: unset. css:: Url which specifies the css document to include in all cgit pages.

@@ -196,12 +207,6 @@ local-time::

Flag which, if set to "1", makes cgit print commit and tag times in the servers timezone. Default value: "0". -commit-sort:: - Flag which, when set to "date", enables strict date ordering in the - commit log, and when set to "topo" enables strict topological - ordering. If unset, the default ordering of "git log" is used. Default - value: unset. - logo:: Url which specifies the source of an image which will be used as a logo on all cgit pages. Default value: "/cgit.png".

@@ -298,6 +303,12 @@

repo.group:: Legacy alias for "section". This option is deprecated and will not be supported in cgit-1.0. + +repository-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-sort. robots:: Text used as content for the "robots" meta-tag. Default value:

@@ -339,12 +350,6 @@ The name of the current repository section - all repositories defined

after this option will inherit the current section name. Default value: none. -repository-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-sort. - section-sort:: Flag which, when set to "1", will sort the sections on the repository listing by name. Set this flag to "0" if the order in the cgitrc file should

@@ -409,6 +414,11 @@ repo.about-filter::

Override the default about-filter. Default value: none. See also: "enable-filter-overrides". See also: "FILTER API". +repo.branch-sort:: + Flag which, when set to "age", enables date ordering in the branch ref + list, and when set to "name" enables ordering by branch name. Default + value: "name". + repo.clone-url:: A list of space-separated urls which can be used to clone this repo. Default value: none. See also: "MACRO EXPANSION".

@@ -416,6 +426,12 @@

repo.commit-filter:: Override the default commit-filter. Default value: none. See also: "enable-filter-overrides". See also: "FILTER API". + +repo.commit-sort:: + Flag which, when set to "date", enables strict date ordering in the + commit log, and when set to "topo" enables strict topological + ordering. If unset, the default ordering of "git log" is used. Default + value: unset. repo.defbranch:: The name of the default branch for this repository. If no such branch

@@ -445,12 +461,6 @@

repo.enable-subject-links:: A flag which can be used to override the global setting `enable-subject-links'. Default value: none. - -repo.commit-sort:: - Flag which, when set to "date", enables strict date ordering in the - commit log, and when set to "topo" enables strict topological - ordering. If unset, the default ordering of "git log" is used. Default - value: unset. repo.logo:: Url which specifies the source of an image which will be used as a logo
M shared.cshared.c

@@ -63,6 +63,7 @@ ret->enable_log_linecount = ctx.cfg.enable_log_linecount;

ret->enable_remote_branches = ctx.cfg.enable_remote_branches; ret->enable_subject_links = ctx.cfg.enable_subject_links; ret->max_stats = ctx.cfg.max_stats; + ret->branch_sort = ctx.cfg.branch_sort; ret->commit_sort = ctx.cfg.commit_sort; ret->module_link = ctx.cfg.module_link; ret->readme = ctx.cfg.readme;
M ui-refs.cui-refs.c

@@ -197,10 +197,9 @@

if (maxcount == 0 || maxcount > list.count) maxcount = list.count; - if (maxcount < list.count) { - qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); + qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); + if (ctx.repo->branch_sort == 0) qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); - } for (i = 0; i < maxcount; i++) print_branch(list.refs[i]);