]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1309-early-config.sh
gitweb: correctly store previous rev in javascript-actions mode
[thirdparty/git.git] / t / t1309-early-config.sh
CommitLineData
1a6ec1eb
JS
1#!/bin/sh
2
3test_description='Test read_early_config()'
4
5. ./test-lib.sh
6
7test_expect_success 'read early config' '
8 test_config early.config correct &&
0e2678af 9 test-tool config read_early_config early.config >output &&
1a6ec1eb
JS
10 test correct = "$(cat output)"
11'
12
13test_expect_success 'in a sub-directory' '
14 test_config early.config sub &&
15 mkdir -p sub &&
16 (
17 cd sub &&
0e2678af 18 test-tool config read_early_config early.config
1a6ec1eb
JS
19 ) >output &&
20 test sub = "$(cat output)"
21'
22
23test_expect_success 'ceiling' '
24 test_config early.config ceiling &&
25 mkdir -p sub &&
26 (
27 GIT_CEILING_DIRECTORIES="$PWD" &&
28 export GIT_CEILING_DIRECTORIES &&
29 cd sub &&
0e2678af 30 test-tool config read_early_config early.config
1a6ec1eb
JS
31 ) >output &&
32 test -z "$(cat output)"
33'
34
35test_expect_success 'ceiling #2' '
36 mkdir -p xdg/git &&
37 git config -f xdg/git/config early.config xdg &&
38 test_config early.config ceiling &&
39 mkdir -p sub &&
40 (
41 XDG_CONFIG_HOME="$PWD"/xdg &&
42 GIT_CEILING_DIRECTORIES="$PWD" &&
43 export GIT_CEILING_DIRECTORIES XDG_CONFIG_HOME &&
44 cd sub &&
0e2678af 45 test-tool config read_early_config early.config
1a6ec1eb
JS
46 ) >output &&
47 test xdg = "$(cat output)"
48'
49
e145a0bc
NTND
50cmdline_config="'test.source=cmdline'"
51test_expect_success 'read config file in right order' '
52 echo "[test]source = home" >>.gitconfig &&
53 git init foo &&
54 (
55 cd foo &&
56 echo "[test]source = repo" >>.git/config &&
0e2678af 57 GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config \
e145a0bc
NTND
58 read_early_config test.source >actual &&
59 cat >expected <<-\EOF &&
60 home
61 repo
62 cmdline
63 EOF
64 test_cmp expected actual
65 )
66'
67
751d3b94
JS
68test_with_config () {
69 rm -rf throwaway &&
70 git init throwaway &&
71 (
72 cd throwaway &&
73 echo "$*" >.git/config &&
0e2678af 74 test-tool config read_early_config early.config
751d3b94
JS
75 )
76}
77
78test_expect_success 'ignore .git/ with incompatible repository version' '
79 test_with_config "[core]repositoryformatversion = 999999" 2>err &&
0d75bfe6 80 test_i18ngrep "warning:.* Expected git repo version <= [1-9]" err
751d3b94
JS
81'
82
83test_expect_failure 'ignore .git/ with invalid repository version' '
84 test_with_config "[core]repositoryformatversion = invalid"
85'
86
87
88test_expect_failure 'ignore .git/ with invalid config' '
89 test_with_config "["
90'
91
85fe0e80
JS
92test_expect_success 'early config and onbranch' '
93 echo "[broken" >broken &&
94 test_with_config "[includeif \"onbranch:refs/heads/master\"]path=../broken"
95'
96
1a6ec1eb 97test_done