Merge branch 'rj/cygwin-has-dev-tty'
[git/gitster.git] / t / t5532-fetch-proxy.sh
blobd664912799b43aef1b0a35d4d4a87ac95de36f4a
1 #!/bin/sh
3 test_description='fetching via git:// using core.gitproxy'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup remote repo' '
9 git init remote &&
10 (cd remote &&
11 echo content >file &&
12 git add file &&
13 git commit -m one
17 test_expect_success 'setup proxy script' '
18 write_script proxy-get-cmd "$PERL_PATH" <<-\EOF &&
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 EOF
28 write_script proxy <<-\EOF
29 echo >&2 "proxying for $*"
30 cmd=$(./proxy-get-cmd)
31 echo >&2 "Running $cmd"
32 exec $cmd
33 EOF
36 test_expect_success 'setup local repo' '
37 git remote add fake git://example.com/remote &&
38 git config core.gitproxy ./proxy
41 test_expect_success 'fetch through proxy works' '
42 git fetch fake &&
43 echo one >expect &&
44 git log -1 --format=%s FETCH_HEAD >actual &&
45 test_cmp expect actual
48 test_expect_success 'funny hostnames are rejected before running proxy' '
49 test_must_fail git fetch git://-remote/repo.git 2>stderr &&
50 ! grep "proxying for" stderr
53 test_done