git.txt: update description of the configuration mechanism
[git.git] / t / t5532-fetch-proxy.sh
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_PATH" -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