Sync with maint
[git/raj.git] / t / t2404-worktree-config.sh
blob286121d8decbf8572bc6c60b1cb9524116156ef2
1 #!/bin/sh
3 test_description="config file in multi worktree"
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 test_commit start
11 test_expect_success 'config --worktree in single worktree' '
12 git config --worktree foo.bar true &&
13 test_cmp_config true foo.bar
16 test_expect_success 'add worktrees' '
17 git worktree add wt1 &&
18 git worktree add wt2
21 test_expect_success 'config --worktree without extension' '
22 test_must_fail git config --worktree foo.bar false
25 test_expect_success 'enable worktreeConfig extension' '
26 git config extensions.worktreeConfig true &&
27 test_cmp_config true extensions.worktreeConfig
30 test_expect_success 'config is shared as before' '
31 git config this.is shared &&
32 test_cmp_config shared this.is &&
33 test_cmp_config -C wt1 shared this.is &&
34 test_cmp_config -C wt2 shared this.is
37 test_expect_success 'config is shared (set from another worktree)' '
38 git -C wt1 config that.is also-shared &&
39 test_cmp_config also-shared that.is &&
40 test_cmp_config -C wt1 also-shared that.is &&
41 test_cmp_config -C wt2 also-shared that.is
44 test_expect_success 'config private to main worktree' '
45 git config --worktree this.is for-main &&
46 test_cmp_config for-main this.is &&
47 test_cmp_config -C wt1 shared this.is &&
48 test_cmp_config -C wt2 shared this.is
51 test_expect_success 'config private to linked worktree' '
52 git -C wt1 config --worktree this.is for-wt1 &&
53 test_cmp_config for-main this.is &&
54 test_cmp_config -C wt1 for-wt1 this.is &&
55 test_cmp_config -C wt2 shared this.is
58 test_expect_success 'core.bare no longer for main only' '
59 test_config core.bare true &&
60 test "$(git rev-parse --is-bare-repository)" = true &&
61 test "$(git -C wt1 rev-parse --is-bare-repository)" = true &&
62 test "$(git -C wt2 rev-parse --is-bare-repository)" = true
65 test_expect_success 'per-worktree core.bare is picked up' '
66 git -C wt1 config --worktree core.bare true &&
67 test "$(git rev-parse --is-bare-repository)" = false &&
68 test "$(git -C wt1 rev-parse --is-bare-repository)" = true &&
69 test "$(git -C wt2 rev-parse --is-bare-repository)" = false
72 test_expect_success 'config.worktree no longer read without extension' '
73 git config --unset extensions.worktreeConfig &&
74 test_cmp_config shared this.is &&
75 test_cmp_config -C wt1 shared this.is &&
76 test_cmp_config -C wt2 shared this.is
79 test_done