t / t5532-fetch-proxy.shon commit Merge branch 'tb/complete-word-diff-regex' into maint (081363d)
   1#!/bin/sh
   2
   3test_description='fetching via git:// using core.gitproxy'
   4. ./test-lib.sh
   5
   6test_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
  15cat >proxy <<'EOF'
  16#!/bin/sh
  17echo >&2 "proxying for $*"
  18cmd=`"$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'`
  27echo >&2 "Running '$cmd'"
  28exec $cmd
  29EOF
  30chmod +x proxy
  31test_expect_success 'setup local repo' '
  32        git remote add fake git://example.com/remote &&
  33        git config core.gitproxy ./proxy
  34'
  35
  36test_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
  43test_done