1#!/bin/sh
23
test_description='fetching via git:// using core.gitproxy'
4. ./test-lib.sh
56
test_expect_success 'setup remote repo' '
7git init remote &&
8(cd remote &&
9echo content >file &&
10git add file &&
11git commit -m one
12)
13'
1415
cat >proxy <<'EOF'
16#!/bin/sh
17echo >&2 "proxying for $*"
18cmd=`"$PERL_PATH" -e '
19read(STDIN, $buf, 4);
20my $n = hex($buf) - 4;
21read(STDIN, $buf, $n);
22my ($cmd, $other) = split /\0/, $buf;
23# drop absolute-path on repo name
24$cmd =~ s{ /}{ };
25print $cmd;
26'`
27echo >&2 "Running '$cmd'"
28exec $cmd
29EOF
30chmod +x proxy
31test_expect_success 'setup local repo' '
32git remote add fake git://example.com/remote &&
33git config core.gitproxy ./proxy
34'
3536
test_expect_success 'fetch through proxy works' '
37git fetch fake &&
38echo one >expect &&
39git log -1 --format=%s FETCH_HEAD >actual &&
40test_cmp expect actual
41'
4243
test_expect_success 'funny hostnames are rejected before running proxy' '
44test_must_fail git fetch git://-remote/repo.git 2>stderr &&
45! grep "proxying for" stderr
46'
4748
test_done