3 test_description
='test automatic tag following'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 # End state of the repository:
14 # L - A ------ O ------ B
19 test_expect_success setup
'
24 L=$(git rev-parse --verify HEAD) &&
30 git remote add -f origin ..
37 A=$(git rev-parse --verify HEAD)
43 test_expect_success
'setup expect' '
52 next unless $F[1] eq "upload-pack<";
53 next unless $F[2] eq "want";
54 print $F[2], " ", $F[3];
58 test_expect_success
'fetch A (new commit : 1 connection)' '
62 GIT_TRACE_PACKET=$UPATH git fetch &&
63 test $A = $(git rev-parse --verify origin/main)
65 get_needs $U >actual &&
66 test_cmp expect actual
69 test_expect_success
"create tag T on A, create C on branch cat" '
70 git tag -a -m tag1 tag1 $A &&
71 T=$(git rev-parse --verify tag1) &&
73 git checkout -b cat &&
77 C=$(git rev-parse --verify HEAD) &&
81 test_expect_success
'setup expect' '
88 test_expect_success
'fetch C, T (new branch, tag : 1 connection)' '
92 GIT_TRACE_PACKET=$UPATH git fetch &&
93 test $C = $(git rev-parse --verify origin/cat) &&
94 test $T = $(git rev-parse --verify tag1) &&
95 test $A = $(git rev-parse --verify tag1^0)
97 get_needs $U >actual &&
98 test_cmp expect actual
101 test_expect_success
"create commits O, B, tag S on B" '
111 B=$(git rev-parse --verify HEAD) &&
113 git tag -a -m tag2 tag2 $B &&
114 S=$(git rev-parse --verify tag2)
117 test_expect_success
'setup expect' '
124 test_expect_success
'fetch B, S (commit and tag : 1 connection)' '
128 GIT_TRACE_PACKET=$UPATH git fetch &&
129 test $B = $(git rev-parse --verify origin/main) &&
130 test $B = $(git rev-parse --verify tag2^0) &&
131 test $S = $(git rev-parse --verify tag2)
133 get_needs $U >actual &&
134 test_cmp expect actual
137 test_expect_success
'setup expect' '
144 test_expect_success
'new clone fetch main and tags' '
145 test_might_fail git branch -D cat &&
151 git remote add origin .. &&
152 GIT_TRACE_PACKET=$UPATH git fetch &&
153 test $B = $(git rev-parse --verify origin/main) &&
154 test $S = $(git rev-parse --verify tag2) &&
155 test $B = $(git rev-parse --verify tag2^0) &&
156 test $T = $(git rev-parse --verify tag1) &&
157 test $A = $(git rev-parse --verify tag1^0)
159 get_needs $U >actual &&
160 test_cmp expect actual