List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] ui-repolist: Tweak max-repo-count handling
@ 2015-06-18 12:18 rep.dot.nop
  2015-06-18 13:02 ` john
  0 siblings, 1 reply; 4+ messages in thread
From: rep.dot.nop @ 2015-06-18 12:18 UTC (permalink / raw)


A max-repo-count less than or equal to 0 now disables repository
pagination.

Previously a value of 0 or smaller went into an infinite loop just
printing pagination links without any repo.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 cgitrc.5.txt  | 3 ++-
 ui-repolist.c | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index e21ece9..0a2a402 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -270,7 +270,8 @@ max-message-length::
 
 max-repo-count::
 	Specifies the number of entries to list per page on the	repository
-	index page. Default value: "50".
+	index page. A value of 0 or a negative number disables repository
+	paging. Default value: "50".
 
 max-repodesc-length::
 	Specifies the maximum number of repo description characters to display
diff --git a/ui-repolist.c b/ui-repolist.c
index 2453a7f..8755dc1 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -282,7 +282,8 @@ void cgit_print_repolist(void)
 		hits++;
 		if (hits <= ctx.qry.ofs)
 			continue;
-		if (hits > ctx.qry.ofs + ctx.cfg.max_repo_count)
+		if (ctx.cfg.max_repo_count > 0 &&
+		    hits > ctx.qry.ofs + ctx.cfg.max_repo_count)
 			continue;
 		if (!header++)
 			print_header();
@@ -339,7 +340,8 @@ void cgit_print_repolist(void)
 	html("</table>");
 	if (!hits)
 		cgit_print_error("No repositories found");
-	else if (hits > ctx.cfg.max_repo_count)
+	else if (ctx.cfg.max_repo_count > 0 &&
+		 hits > ctx.cfg.max_repo_count)
 		print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search, ctx.qry.sort);
 	cgit_print_docend();
 }
-- 
2.1.4



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ui-repolist: Tweak max-repo-count handling
  2015-06-18 12:18 [PATCH] ui-repolist: Tweak max-repo-count handling rep.dot.nop
@ 2015-06-18 13:02 ` john
  2015-06-18 13:48   ` rep.dot.nop
  0 siblings, 1 reply; 4+ messages in thread
From: john @ 2015-06-18 13:02 UTC (permalink / raw)


On Thu, Jun 18, 2015 at 02:18:32PM +0200, Bernhard Reutner-Fischer wrote:
> A max-repo-count less than or equal to 0 now disables repository
> pagination.
> 
> Previously a value of 0 or smaller went into an infinite loop just
> printing pagination links without any repo.
> 
> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
> ---
>  cgitrc.5.txt  | 3 ++-
>  ui-repolist.c | 6 ++++--
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/cgitrc.5.txt b/cgitrc.5.txt
> index e21ece9..0a2a402 100644
> --- a/cgitrc.5.txt
> +++ b/cgitrc.5.txt
> @@ -270,7 +270,8 @@ max-message-length::
>  
>  max-repo-count::
>  	Specifies the number of entries to list per page on the	repository
> -	index page. Default value: "50".
> +	index page. A value of 0 or a negative number disables repository
> +	paging. Default value: "50".
>  
>  max-repodesc-length::
>  	Specifies the maximum number of repo description characters to display
> diff --git a/ui-repolist.c b/ui-repolist.c
> index 2453a7f..8755dc1 100644
> --- a/ui-repolist.c
> +++ b/ui-repolist.c
> @@ -282,7 +282,8 @@ void cgit_print_repolist(void)
>  		hits++;
>  		if (hits <= ctx.qry.ofs)
>  			continue;
> -		if (hits > ctx.qry.ofs + ctx.cfg.max_repo_count)
> +		if (ctx.cfg.max_repo_count > 0 &&
> +		    hits > ctx.qry.ofs + ctx.cfg.max_repo_count)
>  			continue;
>  		if (!header++)
>  			print_header();
> @@ -339,7 +340,8 @@ void cgit_print_repolist(void)
>  	html("</table>");
>  	if (!hits)
>  		cgit_print_error("No repositories found");
> -	else if (hits > ctx.cfg.max_repo_count)
> +	else if (ctx.cfg.max_repo_count > 0 &&
> +		 hits > ctx.cfg.max_repo_count)
>  		print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search, ctx.qry.sort);
>  	cgit_print_docend();
>  }

This feels a bit fragile, in that ever use of the max_repo_count
variable needs to check this explicitly.  Would it be better to simply
set the value to MAX_INT if the config file has a value <= 0?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ui-repolist: Tweak max-repo-count handling
  2015-06-18 13:02 ` john
@ 2015-06-18 13:48   ` rep.dot.nop
  2016-06-09 15:32     ` rep.dot.nop
  0 siblings, 1 reply; 4+ messages in thread
From: rep.dot.nop @ 2015-06-18 13:48 UTC (permalink / raw)


On 18 June 2015 at 15:02, John Keeping <john at keeping.me.uk> wrote:
> On Thu, Jun 18, 2015 at 02:18:32PM +0200, Bernhard Reutner-Fischer wrote:
>> A max-repo-count less than or equal to 0 now disables repository
>> pagination.
>>
>> Previously a value of 0 or smaller went into an infinite loop just
>> printing pagination links without any repo.
>
> This feels a bit fragile, in that ever use of the max_repo_count
> variable needs to check this explicitly.  Would it be better to simply
> set the value to MAX_INT if the config file has a value <= 0?

Conceptually it feels wrong to use a (high) number to turn something off.

thanks,


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ui-repolist: Tweak max-repo-count handling
  2015-06-18 13:48   ` rep.dot.nop
@ 2016-06-09 15:32     ` rep.dot.nop
  0 siblings, 0 replies; 4+ messages in thread
From: rep.dot.nop @ 2016-06-09 15:32 UTC (permalink / raw)


On 18 June 2015 at 15:48, Bernhard Reutner-Fischer
<rep.dot.nop at gmail.com> wrote:
> On 18 June 2015 at 15:02, John Keeping <john at keeping.me.uk> wrote:
>> On Thu, Jun 18, 2015 at 02:18:32PM +0200, Bernhard Reutner-Fischer wrote:
>>> A max-repo-count less than or equal to 0 now disables repository
>>> pagination.
>>>
>>> Previously a value of 0 or smaller went into an infinite loop just
>>> printing pagination links without any repo.
>>
>> This feels a bit fragile, in that ever use of the max_repo_count
>> variable needs to check this explicitly.  Would it be better to simply
>> set the value to MAX_INT if the config file has a value <= 0?
>
> Conceptually it feels wrong to use a (high) number to turn something off.

That's why i made 0 disable it, yes.

I'm open to other ideas to disable pagination. I just want to be able
to turn it off somehow..

thanks,


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-09 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-18 12:18 [PATCH] ui-repolist: Tweak max-repo-count handling rep.dot.nop
2015-06-18 13:02 ` john
2015-06-18 13:48   ` rep.dot.nop
2016-06-09 15:32     ` rep.dot.nop

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).