cgit

commit fe211c7eef6c7d3e39486d6a7484d3b4debff88f

Author: Lars Hjemli <hjemli@gmail.com>

Add support for config param summary-tags

This parameter can be used to specify max number of tags to show on
the summary page. If not specified, all tags are printed.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>

 cgit.h | 1 +
 shared.c | 3 +++
 ui-summary.c | 10 +++++++---


diff --git a/cgit.h b/cgit.h
index 75e919b739ad1b95ee7321b87a624fa8f2a6b2d8..53e1336d846ea1759fd756013d312b602e93a666 100644
--- a/cgit.h
+++ b/cgit.h
@@ -143,6 +143,7 @@ extern int cgit_cache_dynamic_ttl;
 extern int cgit_cache_static_ttl;
 extern int cgit_cache_max_create_time;
 extern int cgit_summary_log;
+extern int cgit_summary_tags;
 
 extern int cgit_max_msg_len;
 extern int cgit_max_repodesc_len;




diff --git a/shared.c b/shared.c
index d815cb1c5b9e47522e160926f80f9b23b7b54bce..7e5eabaf986ef15dfc2f22f922c0989f126aace0 100644
--- a/shared.c
+++ b/shared.c
@@ -38,6 +38,7 @@ int cgit_cache_dynamic_ttl     =  5;
 int cgit_cache_static_ttl      = -1;
 int cgit_cache_max_create_time =  5;
 int cgit_summary_log           =  0;
+int cgit_summary_tags          =  0;
 int cgit_renamelimit           = -1;
 
 int cgit_max_msg_len = 60;
@@ -181,6 +182,8 @@ 	else if (!strcmp(name, "max-commit-count"))
 		cgit_max_commit_count = atoi(value);
 	else if (!strcmp(name, "summary-log"))
 		cgit_summary_log = atoi(value);
+	else if (!strcmp(name, "summary-tags"))
+		cgit_summary_tags = atoi(value);
 	else if (!strcmp(name, "agefile"))
 		cgit_agefile = xstrdup(value);
 	else if (!strcmp(name, "renamelimit"))




diff --git a/ui-summary.c b/ui-summary.c
index 43582da9a5ea92bda2574f0ee8aa457cf231312d..3d5eda84f1261841606fe12f1430495c77f31b55 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -162,7 +162,7 @@ 	for(i=0; i 		cgit_print_branch(list.refs[i]);
 }
 
-static void cgit_print_tags()
+static void cgit_print_tags(int maxcount)
 {
 	struct reflist list;
 	int i;
@@ -174,8 +174,12 @@ 	for_each_tag_ref(cgit_refs_cb, &list);
 	if (list.count == 0)
 		return;
 	qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age);
+	if (!maxcount)
+		maxcount = list.count;
+	else if (maxcount > list.count)
+		maxcount = list.count;
 	print_tag_header();
-	for(i=0; i<list.count; i++)
+	for(i=0; i<maxcount; i++)
 		print_tag(list.refs[i]);
 }
 
@@ -206,6 +210,6 @@ 	if (cgit_summary_log > 0)
 		html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
 	cgit_print_branches();
 	html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
-	cgit_print_tags();
+	cgit_print_tags(cgit_summary_tags);
 	html("</table>");
 }