aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Baudis <pasky@suse.cz>2007-12-08 12:30:59 +0100
committerJunio C Hamano <gitster@pobox.com>2007-12-16 11:56:27 -0800
commitbc8b95ae4a4b21753e84bbfd28cbcbf1b3f6e0a8 (patch)
treefb43145256aebc5dd3ef75919ce65f78ecb06d6b
parentdfa7c7d221d05499063f9bf95f507af8a882bfeb (diff)
downloadgit-bc8b95ae4a4b21753e84bbfd28cbcbf1b3f6e0a8.tar.gz
git-bc8b95ae4a4b21753e84bbfd28cbcbf1b3f6e0a8.tar.xz
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>
-rwxr-xr-xgitweb/gitweb.perl2
-rwxr-xr-xt/t9500-gitweb-standalone-no-errors.sh25
2 files changed, 26 insertions, 1 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 2a0c46c23..28bb8c393 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1511,7 +1511,7 @@ sub config_to_int {
sub config_to_multi {
my $val = shift;
- return ref($val) ? $val : [ $val ];
+ return ref($val) ? $val : (defined($val) ? [ $val ] : []);
}
sub git_get_project_config {
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index 35fff3ddb..796cd7dba 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -558,6 +558,31 @@ test_expect_success \
test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
+# testing config_to_multi / cloneurl
+
+test_expect_success \
+ 'URL: no project URLs, no base URL' \
+ 'gitweb_run "p=.git;a=summary"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+ 'URL: project URLs via gitweb.url' \
+ 'git config --add gitweb.url git://example.com/git/trash.git &&
+ git config --add gitweb.url http://example.com/git/trash.git &&
+ gitweb_run "p=.git;a=summary"'
+test_debug 'cat gitweb.log'
+
+cat >.git/cloneurl <<\EOF
+git://example.com/git/trash.git
+http://example.com/git/trash.git
+EOF
+
+test_expect_success \
+ 'URL: project URLs via cloneurl file' \
+ 'gitweb_run "p=.git;a=summary"'
+test_debug 'cat gitweb.log'
+
+# ----------------------------------------------------------------------
# gitweb config and repo config
cat >>gitweb_config.perl <<EOF