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
8 TEST_PASSES_SANITIZE_LEAK
=true
11 test_expect_success
'setup' '
21 git commit -a -m b1 &&
27 test_expect_success
'prepare pushable branches' '
29 b1=$(git rev-parse origin/b1) &&
30 b2=$(git rev-parse origin/b2) &&
31 git checkout -b b1 origin/b1 &&
33 git commit -a -m aa-b1 &&
34 git checkout -b b2 origin/b2 &&
36 git commit -a -m aa-b2 &&
38 echo aa-main >>file &&
39 git commit -a -m aa-main
42 test_expect_success
'mixed-success push returns error' '
43 test_must_fail git push origin :
46 test_expect_success
'check tracking branches updated correctly after push' '
47 test "$(git rev-parse origin/main)" = "$(git rev-parse main)"
50 test_expect_success
'check tracking branches not updated for failed refs' '
51 test "$(git rev-parse origin/b1)" = "$b1" &&
52 test "$(git rev-parse origin/b2)" = "$b2"
55 test_expect_success
'deleted branches have their tracking branches removed' '
56 git push origin :b1 &&
57 test "$(git rev-parse origin/b1)" = "origin/b1"
60 test_expect_success
'already deleted tracking branches ignored' '
61 git branch -d -r origin/b3 &&
62 git push origin :b3 >output 2>&1 &&
63 ! grep "^error: " output