]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2404-worktree-config.sh
Merge branch 'ea/blame-use-oideq'
[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' '
98564d80 26 git config core.repositoryformatversion 1 &&
58b284a2 27 git config extensions.worktreeConfig true &&
98564d80
XL
28 test_cmp_config true extensions.worktreeConfig &&
29 test_cmp_config 1 core.repositoryformatversion
58b284a2
NTND
30'
31
32test_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
37'
38
39test_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
44'
45
46test_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
51'
52
53test_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
58'
59
60test_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
65'
66
67test_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
72'
73
74test_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
79'
80
81test_done