]> Sergey Matveev's repositories - public-inbox.git/commitdiff
githttpbackend: allow git to be a regular scalar string
authorEric Wong <e@80x24.org>
Fri, 1 Jul 2016 00:42:44 +0000 (00:42 +0000)
committerEric Wong <e@80x24.org>
Fri, 1 Jul 2016 00:42:44 +0000 (00:42 +0000)
No point in forcing users to pass a hashref/object to
get a single git directory.

lib/PublicInbox/GitHTTPBackend.pm

index 7267a1d76978a2219130926002e2ddb9fcd679cc..4f58c6bbcb82a3e392793c3d765f11d8324fe0cf 100644 (file)
@@ -80,7 +80,7 @@ sub serve_dumb {
                return r(404);
        }
 
-       my $f = "$git->{git_dir}/$path";
+       my $f = (ref $git ? $git->{git_dir} : $git) . '/' . $path;
        return r(404) unless -f $f && -r _; # just in case it's a FIFO :P
        my @st = stat(_);
        my $size = $st[7];
@@ -179,7 +179,7 @@ sub serve_smart {
                my $val = $env->{$name};
                $env{$name} = $val if defined $val;
        }
-       my $git_dir = $git->{git_dir};
+       my $git_dir = ref $git ? $git->{git_dir} : $git;
        $env{GIT_HTTP_EXPORT_ALL} = '1';
        $env{PATH_TRANSLATED} = "$git_dir/$path";
        my %rdr = ( 0 => fileno($in) );