checkout: fix "branch info" memory leaks
[git/debian.git] / t / t5404-tracking-branches.sh
blobcc078896673ae221754a5b65102b559b872dcfd9
1 #!/bin/sh
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-lib.sh
10 test_expect_success 'setup' '
11 echo 1 >file &&
12 git add file &&
13 git commit -m 1 &&
14 git branch b1 &&
15 git branch b2 &&
16 git branch b3 &&
17 git clone . aa &&
18 git checkout b1 &&
19 echo b1 >>file &&
20 git commit -a -m b1 &&
21 git checkout b2 &&
22 echo b2 >>file &&
23 git commit -a -m b2
26 test_expect_success 'prepare pushable branches' '
27 cd aa &&
28 b1=$(git rev-parse origin/b1) &&
29 b2=$(git rev-parse origin/b2) &&
30 git checkout -b b1 origin/b1 &&
31 echo aa-b1 >>file &&
32 git commit -a -m aa-b1 &&
33 git checkout -b b2 origin/b2 &&
34 echo aa-b2 >>file &&
35 git commit -a -m aa-b2 &&
36 git checkout main &&
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
65 test_done