3 test_description
='index file specific tests'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 sane_unset GIT_TEST_SPLIT_INDEX
10 test_expect_success
'setup' '
14 test_expect_success
'bogus GIT_INDEX_VERSION issues warning' '
17 GIT_INDEX_VERSION=2bogus &&
18 export GIT_INDEX_VERSION &&
20 sed "s/[0-9]//" err >actual.err &&
21 sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
22 warning: GIT_INDEX_VERSION set, but the value is invalid.
25 test_cmp expect.err actual.err
29 test_expect_success
'out of bounds GIT_INDEX_VERSION issues warning' '
32 GIT_INDEX_VERSION=1 &&
33 export GIT_INDEX_VERSION &&
35 sed "s/[0-9]//" err >actual.err &&
36 sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
37 warning: GIT_INDEX_VERSION set, but the value is invalid.
40 test_cmp expect.err actual.err
44 test_expect_success
'no warning with bogus GIT_INDEX_VERSION and existing index' '
46 GIT_INDEX_VERSION=1 &&
47 export GIT_INDEX_VERSION &&
48 git add a 2>actual.err &&
49 test_must_be_empty actual.err
53 test_expect_success
'out of bounds index.version issues warning' '
55 sane_unset GIT_INDEX_VERSION &&
57 git config --add index.version 1 &&
59 sed "s/[0-9]//" err >actual.err &&
60 sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
61 warning: index.version set, but the value is invalid.
64 test_cmp expect.err actual.err
68 test_expect_success
'index.skipHash config option' '
70 git -c index.skipHash=true add a &&
71 test_trailing_hash .git/index >hash &&
72 echo $(test_oid zero) >expect &&
73 test_cmp expect hash &&
77 git -c feature.manyFiles=true add a &&
78 test_trailing_hash .git/index >hash &&
82 git -c feature.manyFiles=true \
83 -c index.skipHash=false add a &&
84 test_trailing_hash .git/index >hash &&
88 git -c protocol.file.allow=always submodule add ./ sub &&
89 git config index.skipHash false &&
90 git -C sub config index.skipHash true &&
91 rm -f .git/modules/sub/index &&
94 test_trailing_hash .git/modules/sub/index >hash &&
95 test_cmp expect hash &&
99 test_index_version
() {
100 INDEX_VERSION_CONFIG
=$1 &&
101 FEATURE_MANY_FILES
=$2 &&
103 EXPECTED_OUTPUT_VERSION
=$4 &&
107 if test "$INDEX_VERSION_CONFIG" -ne 0
109 git config
--add index.version
$INDEX_VERSION_CONFIG
111 git config
--add feature.manyFiles
$FEATURE_MANY_FILES
112 if test "$ENV_VAR_VERSION" -ne 0
114 GIT_INDEX_VERSION
=$ENV_VAR_VERSION &&
115 export GIT_INDEX_VERSION
117 unset GIT_INDEX_VERSION
120 echo $EXPECTED_OUTPUT_VERSION >expect
&&
121 git update-index
--show-index-version >actual
&&
122 test_cmp expect actual
126 test_expect_success
'index version config precedence' '
127 test_index_version 0 false 0 2 &&
128 test_index_version 2 false 0 2 &&
129 test_index_version 3 false 0 2 &&
130 test_index_version 4 false 0 4 &&
131 test_index_version 2 false 4 4 &&
132 test_index_version 2 true 0 2 &&
133 test_index_version 0 true 0 4 &&
134 test_index_version 0 true 2 2