gitweb: Make config_to_multi return [] instead of [undef]
This is important for the list of clone urls, where if there are no per-repository clone URL configured, the default base URLs are never used for URL construction without this patch. Add tests for different ways of setting project URLs, just in case. Note that those tests in current form wouldn't detect breakage fixed by this patch, as it only checks for errors and not for expected output. Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Petr Baudis committed
Dec 8, 2007 at 12:30 UTC
bc8b95ae4a4b21753e84bbfd28cbcbf1b3f6e0a8
2 files changed
+26
-1
gitweb/gitweb.perl
+1
-1
@@ -1511,7 +1511,7 @@ sub config_to_int {
1511
sub config_to_multi {
1512
my $val = shift;
1513
1514
- return ref($val) ? $val : [ $val ];
1514
+ return ref($val) ? $val : (defined($val) ? [ $val ] : []);
1515
}
1516
1517
sub git_get_project_config {
t/t9500-gitweb-standalone-no-errors.sh
+25
@@ -557,6 +557,31 @@ test_expect_success \
557
'gitweb_run "p=.git;a=tree;opt=--no-merges"'
558
test_debug 'cat gitweb.log'
559
560
+# ----------------------------------------------------------------------
561
+# testing config_to_multi / cloneurl
562
+
563
+test_expect_success \
564
+ 'URL: no project URLs, no base URL' \
565
+ 'gitweb_run "p=.git;a=summary"'
566
+test_debug 'cat gitweb.log'
567
+
568
+test_expect_success \
569
+ 'URL: project URLs via gitweb.url' \
570
+ 'git config --add gitweb.url git://example.com/git/trash.git &&
571
+ git config --add gitweb.url http://example.com/git/trash.git &&
572
+ gitweb_run "p=.git;a=summary"'
573
+test_debug 'cat gitweb.log'
574
+
575
+cat >.git/cloneurl <<\EOF
576
+git://example.com/git/trash.git
577
+http://example.com/git/trash.git
578
+EOF
579
+
580
+test_expect_success \
581
+ 'URL: project URLs via cloneurl file' \
582
+ 'gitweb_run "p=.git;a=summary"'
583
+test_debug 'cat gitweb.log'
584
+
585
# ----------------------------------------------------------------------
586
# gitweb config and repo config
587