Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Show a full index page for a negative offset
The query parser takes an offset as low as -1, which the stats page
reads as every author, so the index clamps it for itself, as the log
and refs pages already do.
| -rw-r--r-- | source/ui-repolist.c | 5 | |
| -rwxr-xr-x | tests/t0101-index.sh | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/source/ui-repolist.c b/source/ui-repolist.c index 4f79f70..800373e 100644 --- a/source/ui-repolist.c +++ b/source/ui-repolist.c @@ -442,6 +442,11 @@ void cgit_print_repolist(void) else if (ctx.cfg.section_sort) sort_repolist("section"); + // An offset of -1 gets through for the stats page, where it means + // every author, and would start this page a row before the first. + if (ctx.qry.ofs < 0) + ctx.qry.ofs = 0; + currenturl = cgit_currenturl(); html("<table class='list repolist' aria-label='Repositories'>\n"); for (i = 0; i < cgit_repolist.count; i++) { diff --git a/tests/t0101-index.sh b/tests/t0101-index.sh index d3d4469..1fcd615 100755 --- a/tests/t0101-index.sh +++ b/tests/t0101-index.sh @@ -146,6 +146,24 @@ test_expect_success 'the idle column shows the date the age file holds' ' test_grep "<td class=.col-idle.><time class=.age-years. datetime=.2005-04-05T10:00:00Z." tmp ' +# An offset as low as -1 gets through for the stats page, and the index read +# it as a page opening a row before its first, one row short and with no +# page in the pager marked as the current one. +test_expect_success 'a negative offset shows the first page of the index' ' + { + echo "max-repo-count=2" && + cat orderrc + } >pagedrc && + printf "%s\n" c a >expect && + for ofs in 0 -1 -100 + do + cgit_ok pagedrc "ofs=$ofs" >tmp && + sed -n "s/.*class=.col-name toplevel-repo.><a href=.\/.\/.>\(.\)<\/a>.*/\1/p" tmp >order && + test_cmp expect order && + test_grep "<a title=.Page 1. class=.current. aria-current=.page. href=./.>\[1\]</a>" tmp || return 1 + done +' + # Fails unless the index of the config named first, asked for with the query # given second, lists the sections, bracketed, and the repositories under # them in the order the rest name. A section heading spans every column, |
