t / t5503-tagfollow.shon commit Merge branch 'maint' (b0085a7)
   1#!/bin/sh
   2
   3test_description='test automatic tag following'
   4
   5. ./test-lib.sh
   6
   7case $(uname -s) in
   8*MINGW*)
   9        say "GIT_DEBUG_SEND_PACK not supported - skipping tests"
  10        test_done
  11        exit
  12esac
  13
  14# End state of the repository:
  15#
  16#         T - tag1          S - tag2
  17#        /                 /
  18#   L - A ------ O ------ B
  19#    \   \                 \
  20#     \   C - origin/cat    \
  21#      origin/master         master
  22
  23test_expect_success setup '
  24        test_tick &&
  25        echo ichi >file &&
  26        git add file &&
  27        git commit -m L &&
  28        L=$(git rev-parse --verify HEAD) &&
  29
  30        (
  31                mkdir cloned &&
  32                cd cloned &&
  33                git init-db &&
  34                git remote add -f origin ..
  35        ) &&
  36
  37        test_tick &&
  38        echo A >file &&
  39        git add file &&
  40        git commit -m A &&
  41        A=$(git rev-parse --verify HEAD)
  42'
  43
  44U=UPLOAD_LOG
  45
  46cat - <<EOF >expect
  47#S
  48want $A
  49#E
  50EOF
  51test_expect_success 'fetch A (new commit : 1 connection)' '
  52        rm -f $U
  53        (
  54                cd cloned &&
  55                GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
  56                test $A = $(git rev-parse --verify origin/master)
  57        ) &&
  58        test -s $U &&
  59        cut -d" " -f1,2 $U >actual &&
  60        test_cmp expect actual
  61'
  62
  63test_expect_success "create tag T on A, create C on branch cat" '
  64        git tag -a -m tag1 tag1 $A &&
  65        T=$(git rev-parse --verify tag1) &&
  66
  67        git checkout -b cat &&
  68        echo C >file &&
  69        git add file &&
  70        git commit -m C &&
  71        C=$(git rev-parse --verify HEAD) &&
  72        git checkout master
  73'
  74
  75cat - <<EOF >expect
  76#S
  77want $C
  78want $T
  79#E
  80EOF
  81test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '
  82        rm -f $U
  83        (
  84                cd cloned &&
  85                GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
  86                test $C = $(git rev-parse --verify origin/cat) &&
  87                test $T = $(git rev-parse --verify tag1) &&
  88                test $A = $(git rev-parse --verify tag1^0)
  89        ) &&
  90        test -s $U &&
  91        cut -d" " -f1,2 $U >actual &&
  92        test_cmp expect actual
  93'
  94
  95test_expect_success "create commits O, B, tag S on B" '
  96        test_tick &&
  97        echo O >file &&
  98        git add file &&
  99        git commit -m O &&
 100
 101        test_tick &&
 102        echo B >file &&
 103        git add file &&
 104        git commit -m B &&
 105        B=$(git rev-parse --verify HEAD) &&
 106
 107        git tag -a -m tag2 tag2 $B &&
 108        S=$(git rev-parse --verify tag2)
 109'
 110
 111cat - <<EOF >expect
 112#S
 113want $B
 114want $S
 115#E
 116EOF
 117test_expect_success 'fetch B, S (commit and tag : 1 connection)' '
 118        rm -f $U
 119        (
 120                cd cloned &&
 121                GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
 122                test $B = $(git rev-parse --verify origin/master) &&
 123                test $B = $(git rev-parse --verify tag2^0) &&
 124                test $S = $(git rev-parse --verify tag2)
 125        ) &&
 126        test -s $U &&
 127        cut -d" " -f1,2 $U >actual &&
 128        test_cmp expect actual
 129'
 130
 131cat - <<EOF >expect
 132#S
 133want $B
 134want $S
 135#E
 136EOF
 137test_expect_success 'new clone fetch master and tags' '
 138        git branch -D cat
 139        rm -f $U
 140        (
 141                mkdir clone2 &&
 142                cd clone2 &&
 143                git init &&
 144                git remote add origin .. &&
 145                GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
 146                test $B = $(git rev-parse --verify origin/master) &&
 147                test $S = $(git rev-parse --verify tag2) &&
 148                test $B = $(git rev-parse --verify tag2^0) &&
 149                test $T = $(git rev-parse --verify tag1) &&
 150                test $A = $(git rev-parse --verify tag1^0)
 151        ) &&
 152        test -s $U &&
 153        cut -d" " -f1,2 $U >actual &&
 154        test_cmp expect actual
 155'
 156
 157test_done