t / t5503-tagfollow.shon commit Let core.attributesfile default to $XDG_CONFIG_HOME/git/attributes (684e40f)
   1#!/bin/sh
   2
   3test_description='test automatic tag following'
   4
   5. ./test-lib.sh
   6
   7if ! test_have_prereq NOT_MINGW; then
   8        say "GIT_DEBUG_SEND_PACK not supported - skipping tests"
   9fi
  10
  11# End state of the repository:
  12#
  13#         T - tag1          S - tag2
  14#        /                 /
  15#   L - A ------ O ------ B
  16#    \   \                 \
  17#     \   C - origin/cat    \
  18#      origin/master         master
  19
  20test_expect_success NOT_MINGW setup '
  21        test_tick &&
  22        echo ichi >file &&
  23        git add file &&
  24        git commit -m L &&
  25        L=$(git rev-parse --verify HEAD) &&
  26
  27        (
  28                mkdir cloned &&
  29                cd cloned &&
  30                git init-db &&
  31                git remote add -f origin ..
  32        ) &&
  33
  34        test_tick &&
  35        echo A >file &&
  36        git add file &&
  37        git commit -m A &&
  38        A=$(git rev-parse --verify HEAD)
  39'
  40
  41U=UPLOAD_LOG
  42
  43test_expect_success NOT_MINGW 'setup expect' '
  44cat - <<EOF >expect
  45#S
  46want $A
  47#E
  48EOF
  49'
  50
  51test_expect_success NOT_MINGW '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 NOT_MINGW "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
  75test_expect_success NOT_MINGW 'setup expect' '
  76cat - <<EOF >expect
  77#S
  78want $C
  79want $T
  80#E
  81EOF
  82'
  83
  84test_expect_success NOT_MINGW 'fetch C, T (new branch, tag : 1 connection)' '
  85        rm -f $U &&
  86        (
  87                cd cloned &&
  88                GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
  89                test $C = $(git rev-parse --verify origin/cat) &&
  90                test $T = $(git rev-parse --verify tag1) &&
  91                test $A = $(git rev-parse --verify tag1^0)
  92        ) &&
  93        test -s $U &&
  94        cut -d" " -f1,2 $U >actual &&
  95        test_cmp expect actual
  96'
  97
  98test_expect_success NOT_MINGW "create commits O, B, tag S on B" '
  99        test_tick &&
 100        echo O >file &&
 101        git add file &&
 102        git commit -m O &&
 103
 104        test_tick &&
 105        echo B >file &&
 106        git add file &&
 107        git commit -m B &&
 108        B=$(git rev-parse --verify HEAD) &&
 109
 110        git tag -a -m tag2 tag2 $B &&
 111        S=$(git rev-parse --verify tag2)
 112'
 113
 114test_expect_success NOT_MINGW 'setup expect' '
 115cat - <<EOF >expect
 116#S
 117want $B
 118want $S
 119#E
 120EOF
 121'
 122
 123test_expect_success NOT_MINGW 'fetch B, S (commit and tag : 1 connection)' '
 124        rm -f $U &&
 125        (
 126                cd cloned &&
 127                GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
 128                test $B = $(git rev-parse --verify origin/master) &&
 129                test $B = $(git rev-parse --verify tag2^0) &&
 130                test $S = $(git rev-parse --verify tag2)
 131        ) &&
 132        test -s $U &&
 133        cut -d" " -f1,2 $U >actual &&
 134        test_cmp expect actual
 135'
 136
 137test_expect_success NOT_MINGW 'setup expect' '
 138cat - <<EOF >expect
 139#S
 140want $B
 141want $S
 142#E
 143EOF
 144'
 145
 146test_expect_success NOT_MINGW 'new clone fetch master and tags' '
 147        git branch -D cat
 148        rm -f $U
 149        (
 150                mkdir clone2 &&
 151                cd clone2 &&
 152                git init &&
 153                git remote add origin .. &&
 154                GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
 155                test $B = $(git rev-parse --verify origin/master) &&
 156                test $S = $(git rev-parse --verify tag2) &&
 157                test $B = $(git rev-parse --verify tag2^0) &&
 158                test $T = $(git rev-parse --verify tag1) &&
 159                test $A = $(git rev-parse --verify tag1^0)
 160        ) &&
 161        test -s $U &&
 162        cut -d" " -f1,2 $U >actual &&
 163        test_cmp expect actual
 164'
 165
 166test_done