| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='ext::cmd remote "connect" helper' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success setup ' |
| 8 | git config --global protocol.ext.allow user && |
| 9 | test_tick && |
| 10 | git commit --allow-empty -m initial && |
| 11 | test_tick && |
| 12 | git commit --allow-empty -m second && |
| 13 | test_tick && |
| 14 | git commit --allow-empty -m third && |
| 15 | test_tick && |
| 16 | git tag -a -m "tip three" three && |
| 17 | |
| 18 | test_tick && |
| 19 | git commit --allow-empty -m fourth |
| 20 | ' |
| 21 | |
| 22 | test_expect_success clone ' |
| 23 | cmd=$(echo "echo >&2 ext::sh invoked && %S .." | sed -e "s/ /% /g") && |
| 24 | git clone "ext::sh -c %S% ." dst && |
| 25 | git for-each-ref refs/heads/ refs/tags/ >expect && |
| 26 | ( |
| 27 | cd dst && |
| 28 | git config remote.origin.url "ext::sh -c $cmd" && |
| 29 | git for-each-ref refs/heads/ refs/tags/ |
| 30 | ) >actual && |
| 31 | test_cmp expect actual |
| 32 | ' |
| 33 | |
| 34 | test_expect_success 'update following tag' ' |
| 35 | test_tick && |
| 36 | git commit --allow-empty -m fifth && |
| 37 | test_tick && |
| 38 | git tag -a -m "tip five" five && |
| 39 | git for-each-ref refs/heads/ refs/tags/ >expect && |
| 40 | ( |
| 41 | cd dst && |
| 42 | git pull && |
| 43 | git for-each-ref refs/heads/ refs/tags/ >../actual |
| 44 | ) && |
| 45 | test_cmp expect actual |
| 46 | ' |
| 47 | |
| 48 | test_expect_success 'update backfilled tag' ' |
| 49 | test_tick && |
| 50 | git commit --allow-empty -m sixth && |
| 51 | test_tick && |
| 52 | git tag -a -m "tip two" two three^1 && |
| 53 | git for-each-ref refs/heads/ refs/tags/ >expect && |
| 54 | ( |
| 55 | cd dst && |
| 56 | git pull && |
| 57 | git for-each-ref refs/heads/ refs/tags/ >../actual |
| 58 | ) && |
| 59 | test_cmp expect actual |
| 60 | ' |
| 61 | |
| 62 | test_expect_success 'update backfilled tag without primary transfer' ' |
| 63 | test_tick && |
| 64 | git tag -a -m "tip one " one two^1 && |
| 65 | git for-each-ref refs/heads/ refs/tags/ >expect && |
| 66 | ( |
| 67 | cd dst && |
| 68 | git pull && |
| 69 | git for-each-ref refs/heads/ refs/tags/ >../actual |
| 70 | ) && |
| 71 | test_cmp expect actual |
| 72 | ' |
| 73 | |
| 74 | |
| 75 | test_expect_success 'set up fake git-daemon' ' |
| 76 | mkdir remote && |
| 77 | git init --bare remote/one.git && |
| 78 | mkdir remote/host && |
| 79 | git init --bare remote/host/two.git && |
| 80 | write_script fake-daemon <<-\EOF && |
| 81 | git daemon --inetd \ |
| 82 | --informative-errors \ |
| 83 | --export-all \ |
| 84 | --base-path="$TRASH_DIRECTORY/remote" \ |
| 85 | --interpolated-path="$TRASH_DIRECTORY/remote/%H%D" \ |
| 86 | "$TRASH_DIRECTORY/remote" |
| 87 | EOF |
| 88 | export TRASH_DIRECTORY && |
| 89 | PATH=$TRASH_DIRECTORY:$PATH |
| 90 | ' |
| 91 | |
| 92 | test_expect_success 'ext command can connect to git daemon (no vhost)' ' |
| 93 | rm -rf dst && |
| 94 | git clone "ext::fake-daemon %G/one.git" dst |
| 95 | ' |
| 96 | |
| 97 | test_expect_success 'ext command can connect to git daemon (vhost)' ' |
| 98 | rm -rf dst && |
| 99 | git clone "ext::fake-daemon %G/two.git %Vhost" dst |
| 100 | ' |
| 101 | |
| 102 | test_done |