]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Fix reading of cloud tags
authorJunio C Hamano <gitster@pobox.com>
Wed, 15 Oct 2008 04:27:12 +0000 (21:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 Oct 2008 06:38:39 +0000 (23:38 -0700)
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>
gitweb/gitweb.perl

index 11168006cffe9bd2f6c8c27bd1d034c41667e39a..41b68668e841a3fb45a38ba0ec5a274e0d84214d 100755 (executable)
@@ -1805,7 +1805,10 @@ sub git_get_project_ctags {
        my $ctags = {};
 
        $git_dir = "$projectroot/$path";
-       foreach (<$git_dir/ctags/*>) {
+       unless (opendir D, "$git_dir/ctags") {
+               return $ctags;
+       }
+       foreach (grep { -f $_ } map { "$git_dir/ctags/$_" } readdir(D)) {
                open CT, $_ or next;
                my $val = <CT>;
                chomp $val;
@@ -1813,6 +1816,7 @@ sub git_get_project_ctags {
                my $ctag = $_; $ctag =~ s#.*/##;
                $ctags->{$ctag} = $val;
        }
+       closedir D;
        $ctags;
 }