List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] ui-summary.c: Move urls variable into print_urls()
@ 2013-03-05 15:48 cgit
  2013-03-20 19:53 ` Jason
  0 siblings, 1 reply; 2+ messages in thread
From: cgit @ 2013-03-05 15:48 UTC (permalink / raw)


There's no need for this variable to be global. Printing the header in
print_urls() instead of print_url() allows for moving this variable into
print_urls() without having to pass any status to print_url().

Note that this only works as long as we don't call print_urls() more
than once.

Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
---
I am aware of the "columns" code duplication caused by the last two
patches. In order to keep commits atomic, I will deal with those in an
upcoming patch set.

 ui-summary.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/ui-summary.c b/ui-summary.c
index 38639ce..0754bb7 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -13,8 +13,6 @@
 #include "ui-refs.h"
 #include "ui-blob.h"
 
-int urls = 0;
-
 static void print_url(char *base, char *suffix)
 {
 	int columns = 3;
@@ -26,10 +24,6 @@ static void print_url(char *base, char *suffix)
 
 	if (!base || !*base)
 		return;
-	if (urls++ == 0) {
-		htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
-		htmlf("<tr><th class='left' colspan='%d'>Clone</th></tr>\n", columns);
-	}
 	if (suffix && *suffix)
 		base = fmt("%s/%s", base, suffix);
 	htmlf("<tr><td colspan='%d'><a href='", columns);
@@ -42,15 +36,29 @@ static void print_url(char *base, char *suffix)
 static void print_urls(char *txt, char *suffix)
 {
 	char *h = txt, *t, c;
+	int urls = 0;
+	int columns = 3;
+
+	if (ctx.repo->enable_log_filecount)
+		columns++;
+	if (ctx.repo->enable_log_linecount)
+		columns++;
+
 
 	while (h && *h) {
 		while (h && *h == ' ')
 			h++;
+		if (!*h)
+			break;
 		t = h;
 		while (t && *t && *t != ' ')
 			t++;
 		c = *t;
 		*t = 0;
+		if (urls++ == 0) {
+			htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
+			htmlf("<tr><th class='left' colspan='%d'>Clone</th></tr>\n", columns);
+		}
 		print_url(h, suffix);
 		*t = c;
 		h = t;
-- 
1.8.2.rc2.352.g908df73





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

* [PATCH] ui-summary.c: Move urls variable into print_urls()
  2013-03-05 15:48 [PATCH] ui-summary.c: Move urls variable into print_urls() cgit
@ 2013-03-20 19:53 ` Jason
  0 siblings, 0 replies; 2+ messages in thread
From: Jason @ 2013-03-20 19:53 UTC (permalink / raw)


Merged to wip.




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

end of thread, other threads:[~2013-03-20 19:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-05 15:48 [PATCH] ui-summary.c: Move urls variable into print_urls() cgit
2013-03-20 19:53 ` Jason

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).