]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2404-worktree-config.sh
Merge branch 'wb/fsmonitor-bitmap-fix'
[thirdparty/git.git] / t / t2404-worktree-config.sh
CommitLineData
58b284a2
NTND
1#!/bin/sh
2
3test_description="config file in multi worktree"
4
5. ./test-lib.sh
6
7test_expect_success 'setup' '
8 test_commit start
9'
10
11test_expect_success 'config --worktree in single worktree' '
12 git config --worktree foo.bar true &&
13 test_cmp_config true foo.bar
14'
15
16test_expect_success 'add worktrees' '
17 git worktree add wt1 &&
18 git worktree add wt2
19'
20
21test_expect_success 'config --worktree without extension' '
22 test_must_fail git config --worktree foo.bar false
23'
24
25test_expect_success 'enable worktreeConfig extension' '
26 git config extensions.worktreeConfig true &&
27 test_cmp_config true extensions.worktreeConfig
28'
29
30test_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
35'
36
37test_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
42'
43
44test_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
49'
50
51test_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
56'
57
58test_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
63'
64
65test_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
70'
71
72test_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
77'
78
79test_done