Skip to content

Commit c7730e6

Browse files
peffgitster
authored andcommitted
test core.gitproxy configuration
This is just a basic sanity test to see whether core.gitproxy works at all. Until now, we were not testing anywhere. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a1a3fd1 commit c7730e6

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

t/t5532-fetch-proxy.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
test_description='fetching via git:// using core.gitproxy'
4+
. ./test-lib.sh
5+
6+
test_expect_success 'setup remote repo' '
7+
git init remote &&
8+
(cd remote &&
9+
echo content >file &&
10+
git add file &&
11+
git commit -m one
12+
)
13+
'
14+
15+
cat >proxy <<'EOF'
16+
#!/bin/sh
17+
echo >&2 "proxying for $*"
18+
cmd=`perl -e '
19+
read(STDIN, $buf, 4);
20+
my $n = hex($buf) - 4;
21+
read(STDIN, $buf, $n);
22+
my ($cmd, $other) = split /\0/, $buf;
23+
# drop absolute-path on repo name
24+
$cmd =~ s{ /}{ };
25+
print $cmd;
26+
'`
27+
echo >&2 "Running '$cmd'"
28+
exec $cmd
29+
EOF
30+
chmod +x proxy
31+
test_expect_success 'setup local repo' '
32+
git remote add fake git://example.com/remote &&
33+
git config core.gitproxy ./proxy
34+
'
35+
36+
test_expect_success 'fetch through proxy works' '
37+
git fetch fake &&
38+
echo one >expect &&
39+
git log -1 --format=%s FETCH_HEAD >actual &&
40+
test_cmp expect actual
41+
'
42+
43+
test_done

0 commit comments

Comments
 (0)