]>
Commit | Line | Data |
---|---|---|
16ab794b RS |
1 | #!/bin/sh |
2 | ||
3 | test_description='tests for git branch --track' | |
4 | ||
883b98ef | 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 |
16ab794b RS |
9 | . ./test-lib.sh |
10 | ||
11 | test_expect_success 'setup' ' | |
12 | test_commit one && | |
13 | test_commit two | |
14 | ' | |
15 | ||
16 | test_expect_success 'checkout --track -b creates a new tracking branch' ' | |
883b98ef | 17 | git checkout --track -b branch1 main && |
16ab794b RS |
18 | test $(git rev-parse --abbrev-ref HEAD) = branch1 && |
19 | test $(git config --get branch.branch1.remote) = . && | |
883b98ef | 20 | test $(git config --get branch.branch1.merge) = refs/heads/main |
16ab794b RS |
21 | ' |
22 | ||
bb2198fb | 23 | test_expect_success 'checkout --track -b rejects an extra path argument' ' |
883b98ef | 24 | test_must_fail git checkout --track -b branch2 main one.t 2>err && |
6789275d | 25 | test_grep "cannot be used with updating paths" err |
16ab794b RS |
26 | ' |
27 | ||
d3115660 JS |
28 | test_expect_success 'checkout --track -b overrides autoSetupMerge=inherit' ' |
29 | # Set up tracking config on main | |
30 | test_config branch.main.remote origin && | |
31 | test_config branch.main.merge refs/heads/some-branch && | |
32 | test_config branch.autoSetupMerge inherit && | |
33 | # With --track=inherit, we copy the tracking config from main | |
34 | git checkout --track=inherit -b b1 main && | |
35 | test_cmp_config origin branch.b1.remote && | |
36 | test_cmp_config refs/heads/some-branch branch.b1.merge && | |
37 | # With branch.autoSetupMerge=inherit, we do the same | |
38 | git checkout -b b2 main && | |
39 | test_cmp_config origin branch.b2.remote && | |
40 | test_cmp_config refs/heads/some-branch branch.b2.merge && | |
41 | # But --track overrides this | |
42 | git checkout --track -b b3 main && | |
43 | test_cmp_config . branch.b3.remote && | |
44 | test_cmp_config refs/heads/main branch.b3.merge && | |
45 | # And --track=direct does as well | |
46 | git checkout --track=direct -b b4 main && | |
47 | test_cmp_config . branch.b4.remote && | |
48 | test_cmp_config refs/heads/main branch.b4.merge | |
49 | ' | |
50 | ||
16ab794b | 51 | test_done |