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