diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Read a negative ref count as no limit
summary-branches, summary-tags and max-ref-count already listed every
ref at 0, but a negative value reached qsort as a count and crashed the
summary and refs pages, and emptied the branch switcher.
| -rw-r--r-- | MANUAL.txt | 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | custom/cgitrc | 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/ui-refs.c | 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/ui-shared.c | 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rwxr-xr-x | tests/t0204-limits.sh | 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
5 files changed, 33 insertions, 13 deletions
@@ -368,8 +368,8 @@ max-patch-count:: max-ref-count:: Specifies the number of branches and tags to list per section on the "refs" page, and per page on the dedicated branch and tag pages that its - overflow links lead to. Default value: "200". Set to "0" to list every - ref on one page. + overflow links lead to. Default value: "200". A value of "0" or less lists + every ref on one page. max-repo-count:: Specifies the number of entries to list per page on the repository index @@ -526,7 +526,7 @@ strict-export:: summary-branches:: Specifies the number of branches to display in the repository "summary" - page. Default value: "10". + page. Default value: "10". A value of "0" or less lists every branch. summary-log:: Specifies the number of log entries to display in the repository @@ -534,7 +534,7 @@ summary-log:: summary-tags:: Specifies the number of tags to display in the repository "summary" - page. Default value: "10". + page. Default value: "10". A value of "0" or less lists every tag. trailer-filter:: Specifies a command which will be invoked to format the value of a diff --git a/custom/cgitrc b/custom/cgitrc index 1e02f8f..f816f56 100644 --- a/custom/cgitrc +++ b/custom/cgitrc @@ -353,7 +353,8 @@ max-diff-files=200 max-diff-lines=1000 # Branches and tags listed per section on the refs page, and per page on the -# dedicated branch and tag pages. A value of 0 lists everything on one page. +# dedicated branch and tag pages. A value of 0 or less lists everything on one +# page. # Value is an integer. Default is 200. max-ref-count=200 @@ -365,11 +366,12 @@ rename-limit=-1 # is 10. summary-log=10 -# Number of branches shown in the summary page. Value is an integer. Default is -# 10. +# Number of branches shown in the summary page, where 0 or less shows them all. +# Value is an integer. Default is 10. summary-branches=10 -# Number of tags shown in the summary page. Value is an integer. Default is 10. +# Number of tags shown in the summary page, where 0 or less shows them all. +# Value is an integer. Default is 10. summary-tags=10 # Show side-by-side diffs instead of unidiffs by default. Values are 0 or 1. diff --git a/source/ui-refs.c b/source/ui-refs.c index e4a0dd0..890a959 100644 --- a/source/ui-refs.c +++ b/source/ui-refs.c @@ -294,7 +294,7 @@ void cgit_print_branches(int maxcount) print_branch_header(); collect_branches(&list); - if (maxcount == 0 || maxcount > list.count) + if (maxcount <= 0 || maxcount > list.count) maxcount = list.count; // The date sort covers the list, the name sort only the rows about to @@ -323,9 +323,7 @@ void cgit_print_tags(int maxcount) if (list.count == 0) return; qsort(list.refs, list.count, sizeof(*list.refs), cmp_date); - if (!maxcount) - maxcount = list.count; - else if (maxcount > list.count) + if (maxcount <= 0 || maxcount > list.count) maxcount = list.count; print_tag_header(); for (i = 0; i < maxcount; i++) diff --git a/source/ui-shared.c b/source/ui-shared.c index 409ad40..7d28c39 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -485,7 +485,7 @@ static int print_branch_option(const struct reference *ref, void *data) const char *name = ref->name; // The switcher runs on every page, so it is bounded like the refs list. - if (ctx.cfg.max_ref_count && opt->count >= ctx.cfg.max_ref_count) + if (ctx.cfg.max_ref_count > 0 && opt->count >= ctx.cfg.max_ref_count) return -1; // A name spelled like an option is refused as a head, so offering it // would only lead to an error page. diff --git a/tests/t0204-limits.sh b/tests/t0204-limits.sh index 245c016..b1c797a 100755 --- a/tests/t0204-limits.sh +++ b/tests/t0204-limits.sh @@ -105,6 +105,26 @@ test_expect_success 'tag page paginates independently' ' ! grep "log/?h=" tmp ' +# A count of 0 lists every ref, and a negative one has to mean the same +# rather than reach the sort as a size. +test_expect_success 'a negative ref count lists every ref' ' + for n in 0 -1 + do + { + echo "summary-branches=$n" && + echo "summary-tags=$n" && + sed "s/^max-ref-count=2$/max-ref-count=$n/" limitrc + } >count$n.rc && + CGIT_CONFIG="$PWD/count$n.rc" QUERY_STRING="url=limits/refs/" cgit >refs$n && + CGIT_CONFIG="$PWD/count$n.rc" QUERY_STRING="url=limits/" cgit >summary$n || + return 1 + done && + grep "log/?h=branch-3" refs0 && + grep "/tag/?h=tag-3" summary0 && + test_cmp refs0 refs-1 && + test_cmp summary0 summary-1 +' + # A file that busts max-diff-lines is replaced by a link to its own page, # where the reader asked for that one file and the limit no longer applies. # The rest of the commit still renders, so one huge file cannot hide the |
