@matheusbsbs / matheus-bagliano / commits / eee0184da8
Fork 0

Fix reading of cloud tags

The projectroot path could have SP in it, in which case iterating over <$git_dir/ctags/*> does not correctly enumerate the cloud tags files at all. This can be observed by creating an empty t/trash directory and running t9500 test. The $projectroot ends with "trash directory.t9500-gitweb-/" and <$glob> would give "trash", which can be opened and reading from it immediately yields undef, which in turn gives an undef value warning to the standard error stream upon attempt to chomp it. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Oct 14, 2008 at 21:27 UTC eee0184da8457c1dbd4418f95d158917540da094
1 file changed +5 -1
gitweb/gitweb.perl
+5 -1
@@ -1805,7 +1805,10 @@ sub git_get_project_ctags {
1805 my $ctags = {};
1806
1807 $git_dir = "$projectroot/$path";
1808 - foreach (<$git_dir/ctags/*>) {
1808 + unless (opendir D, "$git_dir/ctags") {
1809 + return $ctags;
1810 + }
1811 + foreach (grep { -f $_ } map { "$git_dir/ctags/$_" } readdir(D)) {
1812 open CT, $_ or next;
1813 my $val = <CT>;
1814 chomp $val;
@@ -1813,6 +1816,7 @@ sub git_get_project_ctags {
1816 my $ctag = $_; $ctag =~ s#.*/##;
1817 $ctags->{$ctag} = $val;
1818 }
1819 + closedir D;
1820 $ctags;
1821 }
1822