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