cgit

commit f3c99cf1cee25ae95ffea6188b40734e877bce20

Author: Lars Hjemli <hjemli@gmail.com>

ui-tree.c: do not add blank line when displaying blobs

Also, fix a related bug in the test-suite.

Noticed-by: Jim Meyering <jim@meyering.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>

 tests/t0104-tree.sh | 2 +-
 ui-tree.c | 6 ++++--


diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh
index 0d62cc82c5d5dbbc90e351a73e3c748e427ba7c0..33f4eb00ff2808e9f4335b397e809d695b464301 100755
--- a/tests/t0104-tree.sh
+++ b/tests/t0104-tree.sh
@@ -15,7 +15,7 @@ 	grep -e "1" trash/tmp
 '
 
 run_test 'no line 2' '
-	grep -e "<a id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp
+	! grep -e "<a id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp
 '
 
 run_test 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp'




diff --git a/ui-tree.c b/ui-tree.c
index 79332fc9eb22cc83bf4a098abcaf32102862b4d1..4bf372a6ce73b75984b1959149193b16266e4642 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -54,8 +54,10 @@ 			start = idx + 1;
 		}
 		idx++;
 	}
-	htmlf(linefmt, ++lineno);
-	html_txt(buf + start);
+	if (start < idx) {
+		htmlf(linefmt, ++lineno);
+		html_txt(buf + start);
+	}
 	html("</td></tr>\n");
 	html("</table>\n");
 }