Skip to content

Commit bc8b95a

Browse files
Petr Baudisgitster
authored andcommitted
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>
1 parent dfa7c7d commit bc8b95a

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

gitweb/gitweb.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ sub config_to_int {
15111511
sub config_to_multi {
15121512
my $val = shift;
15131513

1514-
return ref($val) ? $val : [ $val ];
1514+
return ref($val) ? $val : (defined($val) ? [ $val ] : []);
15151515
}
15161516

15171517
sub git_get_project_config {

t/t9500-gitweb-standalone-no-errors.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,31 @@ test_expect_success \
557557
'gitweb_run "p=.git;a=tree;opt=--no-merges"'
558558
test_debug 'cat gitweb.log'
559559

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+
560585
# ----------------------------------------------------------------------
561586
# gitweb config and repo config
562587

0 commit comments

Comments
 (0)