3 test_description
="config file in multi worktree"
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'setup' '
12 test_expect_success
'config --worktree in single worktree' '
13 git config --worktree foo.bar true &&
14 test_cmp_config true foo.bar
17 test_expect_success
'add worktrees' '
18 git worktree add wt1 &&
22 test_expect_success
'config --worktree without extension' '
23 test_must_fail git config --worktree foo.bar false
26 test_expect_success
'enable worktreeConfig extension' '
27 git config core.repositoryformatversion 1 &&
28 git config extensions.worktreeConfig true &&
29 test_cmp_config true extensions.worktreeConfig &&
30 test_cmp_config 1 core.repositoryformatversion
33 test_expect_success
'config is shared as before' '
34 git config this.is shared &&
35 test_cmp_config shared this.is &&
36 test_cmp_config -C wt1 shared this.is &&
37 test_cmp_config -C wt2 shared this.is
40 test_expect_success
'config is shared (set from another worktree)' '
41 git -C wt1 config that.is also-shared &&
42 test_cmp_config also-shared that.is &&
43 test_cmp_config -C wt1 also-shared that.is &&
44 test_cmp_config -C wt2 also-shared that.is
47 test_expect_success
'config private to main worktree' '
48 git config --worktree this.is for-main &&
49 test_cmp_config for-main this.is &&
50 test_cmp_config -C wt1 shared this.is &&
51 test_cmp_config -C wt2 shared this.is
54 test_expect_success
'config private to linked worktree' '
55 git -C wt1 config --worktree this.is for-wt1 &&
56 test_cmp_config for-main this.is &&
57 test_cmp_config -C wt1 for-wt1 this.is &&
58 test_cmp_config -C wt2 shared this.is
61 test_expect_success
'core.bare no longer for main only' '
62 test_config core.bare true &&
63 test "$(git rev-parse --is-bare-repository)" = true &&
64 test "$(git -C wt1 rev-parse --is-bare-repository)" = true &&
65 test "$(git -C wt2 rev-parse --is-bare-repository)" = true
68 test_expect_success
'per-worktree core.bare is picked up' '
69 git -C wt1 config --worktree core.bare true &&
70 test "$(git rev-parse --is-bare-repository)" = false &&
71 test "$(git -C wt1 rev-parse --is-bare-repository)" = true &&
72 test "$(git -C wt2 rev-parse --is-bare-repository)" = false
75 test_expect_success
'config.worktree no longer read without extension' '
76 git config --unset extensions.worktreeConfig &&
77 test_cmp_config shared this.is &&
78 test_cmp_config -C wt1 shared this.is &&
79 test_cmp_config -C wt2 shared this.is