]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2404-worktree-config.sh
The third batch
[thirdparty/git.git] / t / t2404-worktree-config.sh
CommitLineData
58b284a2
NTND
1#!/bin/sh
2
3test_description="config file in multi worktree"
4
67606301 5TEST_PASSES_SANITIZE_LEAK=true
58b284a2
NTND
6. ./test-lib.sh
7
8test_expect_success 'setup' '
9 test_commit start
10'
11
12test_expect_success 'config --worktree in single worktree' '
13 git config --worktree foo.bar true &&
14 test_cmp_config true foo.bar
15'
16
17test_expect_success 'add worktrees' '
18 git worktree add wt1 &&
19 git worktree add wt2
20'
21
22test_expect_success 'config --worktree without extension' '
23 test_must_fail git config --worktree foo.bar false
24'
25
26test_expect_success 'enable worktreeConfig extension' '
98564d80 27 git config core.repositoryformatversion 1 &&
58b284a2 28 git config extensions.worktreeConfig true &&
98564d80
XL
29 test_cmp_config true extensions.worktreeConfig &&
30 test_cmp_config 1 core.repositoryformatversion
58b284a2
NTND
31'
32
33test_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
38'
39
40test_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
45'
46
47test_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
52'
53
54test_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
59'
60
61test_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
66'
67
68test_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
73'
74
75test_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
80'
81
82test_done