Merge branch 'ab/test-lib'
[git/debian.git] / t / t2404-worktree-config.sh
blob9536d1091954b48a87b74eead0c382ce70355c4e
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 core.repositoryformatversion 1 &&
27 git config extensions.worktreeConfig true &&
28 test_cmp_config true extensions.worktreeConfig &&
29 test_cmp_config 1 core.repositoryformatversion
32 test_expect_success 'config is shared as before' '
33 git config this.is shared &&
34 test_cmp_config shared this.is &&
35 test_cmp_config -C wt1 shared this.is &&
36 test_cmp_config -C wt2 shared this.is
39 test_expect_success 'config is shared (set from another worktree)' '
40 git -C wt1 config that.is also-shared &&
41 test_cmp_config also-shared that.is &&
42 test_cmp_config -C wt1 also-shared that.is &&
43 test_cmp_config -C wt2 also-shared that.is
46 test_expect_success 'config private to main worktree' '
47 git config --worktree this.is for-main &&
48 test_cmp_config for-main this.is &&
49 test_cmp_config -C wt1 shared this.is &&
50 test_cmp_config -C wt2 shared this.is
53 test_expect_success 'config private to linked worktree' '
54 git -C wt1 config --worktree this.is for-wt1 &&
55 test_cmp_config for-main this.is &&
56 test_cmp_config -C wt1 for-wt1 this.is &&
57 test_cmp_config -C wt2 shared this.is
60 test_expect_success 'core.bare no longer for main only' '
61 test_config core.bare true &&
62 test "$(git rev-parse --is-bare-repository)" = true &&
63 test "$(git -C wt1 rev-parse --is-bare-repository)" = true &&
64 test "$(git -C wt2 rev-parse --is-bare-repository)" = true
67 test_expect_success 'per-worktree core.bare is picked up' '
68 git -C wt1 config --worktree core.bare true &&
69 test "$(git rev-parse --is-bare-repository)" = false &&
70 test "$(git -C wt1 rev-parse --is-bare-repository)" = true &&
71 test "$(git -C wt2 rev-parse --is-bare-repository)" = false
74 test_expect_success 'config.worktree no longer read without extension' '
75 git config --unset extensions.worktreeConfig &&
76 test_cmp_config shared this.is &&
77 test_cmp_config -C wt1 shared this.is &&
78 test_cmp_config -C wt2 shared this.is
81 test_done