]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5404-tracking-branches.sh
The second batch
[thirdparty/git.git] / t / t5404-tracking-branches.sh
1 #!/bin/sh
2
3 test_description='tracking branch update checks for git push'
4
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 test_expect_success 'setup' '
12 echo 1 >file &&
13 git add file &&
14 git commit -m 1 &&
15 git branch b1 &&
16 git branch b2 &&
17 git branch b3 &&
18 git clone . aa &&
19 git checkout b1 &&
20 echo b1 >>file &&
21 git commit -a -m b1 &&
22 git checkout b2 &&
23 echo b2 >>file &&
24 git commit -a -m b2
25 '
26
27 test_expect_success 'prepare pushable branches' '
28 cd aa &&
29 b1=$(git rev-parse origin/b1) &&
30 b2=$(git rev-parse origin/b2) &&
31 git checkout -b b1 origin/b1 &&
32 echo aa-b1 >>file &&
33 git commit -a -m aa-b1 &&
34 git checkout -b b2 origin/b2 &&
35 echo aa-b2 >>file &&
36 git commit -a -m aa-b2 &&
37 git checkout main &&
38 echo aa-main >>file &&
39 git commit -a -m aa-main
40 '
41
42 test_expect_success 'mixed-success push returns error' '
43 test_must_fail git push origin :
44 '
45
46 test_expect_success 'check tracking branches updated correctly after push' '
47 test "$(git rev-parse origin/main)" = "$(git rev-parse main)"
48 '
49
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"
53 '
54
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"
58 '
59
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
64 '
65
66 test_done