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