]>
Commit | Line | Data |
---|---|---|
6fa92bf3 AR |
1 | #!/bin/sh |
2 | ||
3 | test_description='tracking branch update checks for git push' | |
4 | ||
966b4be2 | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
7 | ||
80d32e84 | 8 | TEST_PASSES_SANITIZE_LEAK=true |
6fa92bf3 AR |
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 && | |
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 | 27 | test_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 | 42 | test_expect_success 'mixed-success push returns error' ' |
2f9ae5fc | 43 | test_must_fail git push origin : |
d492b31c | 44 | ' |
8736a848 JK |
45 | |
46 | test_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 | ||
50 | test_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 |
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 | ||
0b294c0a JK |
60 | test_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 | 66 | test_done |