]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5404-tracking-branches.sh
The fifteenth batch
[thirdparty/git.git] / t / t5404-tracking-branches.sh
CommitLineData
6fa92bf3
AR
1#!/bin/sh
2
3test_description='tracking branch update checks for git push'
4
966b4be2 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
80d32e84 8TEST_PASSES_SANITIZE_LEAK=true
6fa92bf3
AR
9. ./test-lib.sh
10
11test_expect_success 'setup' '
12 echo 1 >file &&
13 git add file &&
14 git commit -m 1 &&
15 git branch b1 &&
16 git branch b2 &&
0b294c0a 17 git branch b3 &&
6fa92bf3
AR
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
8736a848 27test_expect_success 'prepare pushable branches' '
6fa92bf3
AR
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 &&
966b4be2
JS
37 git checkout main &&
38 echo aa-main >>file &&
39 git commit -a -m aa-main
8736a848
JK
40'
41
d492b31c 42test_expect_success 'mixed-success push returns error' '
2f9ae5fc 43 test_must_fail git push origin :
d492b31c 44'
8736a848
JK
45
46test_expect_success 'check tracking branches updated correctly after push' '
966b4be2 47 test "$(git rev-parse origin/main)" = "$(git rev-parse main)"
8736a848
JK
48'
49
50test_expect_success 'check tracking branches not updated for failed refs' '
6fa92bf3
AR
51 test "$(git rev-parse origin/b1)" = "$b1" &&
52 test "$(git rev-parse origin/b2)" = "$b2"
53'
54
1f0e2a1a
JK
55test_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
0b294c0a
JK
60test_expect_success 'already deleted tracking branches ignored' '
61 git branch -d -r origin/b3 &&
62 git push origin :b3 >output 2>&1 &&
43b44ccf 63 ! grep "^error: " output
0b294c0a
JK
64'
65
6fa92bf3 66test_done