3 test_description
='tracking branch update checks for git push'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 test_expect_success
'setup' '
20 git commit -a -m b1 &&
26 test_expect_success
'prepare pushable branches' '
28 b1=$(git rev-parse origin/b1) &&
29 b2=$(git rev-parse origin/b2) &&
30 git checkout -b b1 origin/b1 &&
32 git commit -a -m aa-b1 &&
33 git checkout -b b2 origin/b2 &&
35 git commit -a -m aa-b2 &&
37 echo aa-main >>file &&
38 git commit -a -m aa-main
41 test_expect_success
'mixed-success push returns error' '
42 test_must_fail git push origin :
45 test_expect_success
'check tracking branches updated correctly after push' '
46 test "$(git rev-parse origin/main)" = "$(git rev-parse main)"
49 test_expect_success
'check tracking branches not updated for failed refs' '
50 test "$(git rev-parse origin/b1)" = "$b1" &&
51 test "$(git rev-parse origin/b2)" = "$b2"
54 test_expect_success
'deleted branches have their tracking branches removed' '
55 git push origin :b1 &&
56 test "$(git rev-parse origin/b1)" = "origin/b1"
59 test_expect_success
'already deleted tracking branches ignored' '
60 git branch -d -r origin/b3 &&
61 git push origin :b3 >output 2>&1 &&
62 ! grep "^error: " output