3 test_description
='test automatic tag following'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
11 # End state of the repository:
15 # L - A ------ O ------ B
20 test_expect_success setup
'
25 L=$(git rev-parse --verify HEAD) &&
31 git remote add -f origin ..
38 A=$(git rev-parse --verify HEAD)
44 test_expect_success
'setup expect' '
53 next unless $F[1] eq "upload-pack<";
54 next unless $F[2] eq "want";
55 print $F[2], " ", $F[3];
59 test_expect_success
'fetch A (new commit : 1 connection)' '
63 GIT_TRACE_PACKET=$UPATH git fetch &&
64 test $A = $(git rev-parse --verify origin/main)
66 get_needs $U >actual &&
67 test_cmp expect actual
70 test_expect_success
"create tag T on A, create C on branch cat" '
71 git tag -a -m tag1 tag1 $A &&
72 T=$(git rev-parse --verify tag1) &&
74 git checkout -b cat &&
78 C=$(git rev-parse --verify HEAD) &&
82 test_expect_success
'setup expect' '
89 test_expect_success
'fetch C, T (new branch, tag : 1 connection)' '
93 GIT_TRACE_PACKET=$UPATH git fetch &&
94 test $C = $(git rev-parse --verify origin/cat) &&
95 test $T = $(git rev-parse --verify tag1) &&
96 test $A = $(git rev-parse --verify tag1^0)
98 get_needs $U >actual &&
99 test_cmp expect actual
102 test_expect_success
"create commits O, B, tag S on B" '
112 B=$(git rev-parse --verify HEAD) &&
114 git tag -a -m tag2 tag2 $B &&
115 S=$(git rev-parse --verify tag2)
118 test_expect_success
'setup expect' '
125 test_expect_success
'fetch B, S (commit and tag : 1 connection)' '
129 GIT_TRACE_PACKET=$UPATH git fetch &&
130 test $B = $(git rev-parse --verify origin/main) &&
131 test $B = $(git rev-parse --verify tag2^0) &&
132 test $S = $(git rev-parse --verify tag2)
134 get_needs $U >actual &&
135 test_cmp expect actual
138 test_expect_success
'setup expect' '
145 test_expect_success
'new clone fetch main and tags' '
146 test_might_fail git branch -D cat &&
152 git remote add origin .. &&
153 GIT_TRACE_PACKET=$UPATH git fetch &&
154 test $B = $(git rev-parse --verify origin/main) &&
155 test $S = $(git rev-parse --verify tag2) &&
156 test $B = $(git rev-parse --verify tag2^0) &&
157 test $T = $(git rev-parse --verify tag1) &&
158 test $A = $(git rev-parse --verify tag1^0)
160 get_needs $U >actual &&
161 test_cmp expect actual