Skip to content

Commit bf8f2ad

Browse files
committed
Merge branch 'maint'
* maint: gitweb: Add path_info tests to t/t9500-gitweb-standalone-no-errors.sh gitweb: Fix two 'uninitialized value' warnings in git_tree() Solaris: Use OLD_ICONV to avoid compile warnings gitweb: remove PATH_INFO from $my_url and $my_uri
2 parents 9126f00 + 9a1fd65 commit bf8f2ad

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ ifeq ($(uname_S),SunOS)
648648
NO_MEMMEM = YesPlease
649649
NO_HSTRERROR = YesPlease
650650
NO_MKDTEMP = YesPlease
651+
OLD_ICONV = UnfortunatelyYes
651652
ifeq ($(uname_R),5.8)
652653
NEEDS_LIBICONV = YesPlease
653654
NO_UNSETENV = YesPlease

gitweb/gitweb.perl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ BEGIN
2727
our $my_url = $cgi->url();
2828
our $my_uri = $cgi->url(-absolute => 1);
2929

30+
# if we're called with PATH_INFO, we have to strip that
31+
# from the URL to find our real URL
32+
if (my $path_info = $ENV{"PATH_INFO"}) {
33+
$my_url =~ s,\Q$path_info\E$,,;
34+
$my_uri =~ s,\Q$path_info\E$,,;
35+
}
36+
3037
# core git executable to use
3138
# this can just be "git" if your webserver has a sensible PATH
3239
our $GIT = "++GIT_BINDIR++/git";
@@ -4445,6 +4452,7 @@ sub git_tree {
44454452
$hash = $hash_base;
44464453
}
44474454
}
4455+
die_error(404, "No such tree") unless defined($hash);
44484456
$/ = "\0";
44494457
open my $fd, "-|", git_cmd(), "ls-tree", '-z', $hash
44504458
or die_error(500, "Open git-ls-tree failed");
@@ -4485,8 +4493,8 @@ sub git_tree {
44854493
if ($basedir ne '' && substr($basedir, -1) ne '/') {
44864494
$basedir .= '/';
44874495
}
4496+
git_print_page_path($file_name, 'tree', $hash_base);
44884497
}
4489-
git_print_page_path($file_name, 'tree', $hash_base);
44904498
print "<div class=\"page_body\">\n";
44914499
print "<table class=\"tree\">\n";
44924500
my $alternate = 1;

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,55 @@ test_expect_success \
502502
gitweb_run "p=.git;a=history;f=deleted_file"'
503503
test_debug 'cat gitweb.log'
504504

505+
# ----------------------------------------------------------------------
506+
# path_info links
507+
test_expect_success \
508+
'path_info: project' \
509+
'gitweb_run "" "/.git"'
510+
test_debug 'cat gitweb.log'
511+
512+
test_expect_success \
513+
'path_info: project/branch' \
514+
'gitweb_run "" "/.git/b"'
515+
test_debug 'cat gitweb.log'
516+
517+
test_expect_success \
518+
'path_info: project/branch:file' \
519+
'gitweb_run "" "/.git/master:file"'
520+
test_debug 'cat gitweb.log'
521+
522+
test_expect_success \
523+
'path_info: project/branch:dir/' \
524+
'gitweb_run "" "/.git/master:foo/"'
525+
test_debug 'cat gitweb.log'
526+
527+
test_expect_success \
528+
'path_info: project/branch:file (non-existent)' \
529+
'gitweb_run "" "/.git/master:non-existent"'
530+
test_debug 'cat gitweb.log'
531+
532+
test_expect_success \
533+
'path_info: project/branch:dir/ (non-existent)' \
534+
'gitweb_run "" "/.git/master:non-existent/"'
535+
test_debug 'cat gitweb.log'
536+
537+
538+
test_expect_success \
539+
'path_info: project/branch:/file' \
540+
'gitweb_run "" "/.git/master:/file"'
541+
test_debug 'cat gitweb.log'
542+
543+
test_expect_success \
544+
'path_info: project/:/file (implicit HEAD)' \
545+
'gitweb_run "" "/.git/:/file"'
546+
test_debug 'cat gitweb.log'
547+
548+
test_expect_success \
549+
'path_info: project/:/ (implicit HEAD, top tree)' \
550+
'gitweb_run "" "/.git/:/"'
551+
test_debug 'cat gitweb.log'
552+
553+
505554
# ----------------------------------------------------------------------
506555
# feed generation
507556

0 commit comments

Comments
 (0)