summaryrefslogtreecommitdiffstats
path: root/t/glt
blob: 1bf31e8865e2202a29ad2837ad904c3f26eb617b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl
use strict;
use warnings;

use FindBin;
BEGIN { $ENV{GL_BINDIR} = $FindBin::RealBin; }

my $cmd  = shift or die "need command";
my $user = shift or die "need user";
my $rc;

my %extcmds = (
    help        => 1,
    info        => 1,
    desc        => 1,
    fork        => 1,
    perms       => 1,
    writable    => 1,
);

$ENV{G3T_USER} = $user;
if ($extcmds{$cmd}) {
    $ENV{SSH_ORIGINAL_COMMAND} = join(" ", $cmd, @ARGV);
    exec( "$ENV{GL_BINDIR}/../src/gitolite-shell", $user );
} elsif ( $cmd eq 'push' ) {
    print STDERR "TRACE: glt(", join( ")(", @ARGV ), ")\n";
    $rc = system( "git", $cmd, "--receive-pack=$ENV{GL_BINDIR}/gitolite-receive-pack", @ARGV );
} else {
    print STDERR "TRACE: glt(", join( ")(", @ARGV ), ")\n";
    $rc = system( "git", $cmd, "--upload-pack=$ENV{GL_BINDIR}/gitolite-upload-pack", @ARGV );
}

if ( $? == -1 ) {
    die "F: failed to execute: $!\n";
} elsif ( $? & 127 ) {
    printf STDERR "E: child died with signal %d\n", ( $? & 127 );
    exit 1;
} else {
    printf STDERR "W: child exited with value %d\n", $? >> 8 if $? >> 8;
    exit( $? >> 8 );
}

exit 0;