3 test_description
='index file specific tests'
7 sane_unset GIT_TEST_SPLIT_INDEX
9 test_expect_success
'setup' '
13 test_expect_success
'bogus GIT_INDEX_VERSION issues warning' '
16 GIT_INDEX_VERSION=2bogus &&
17 export GIT_INDEX_VERSION &&
19 sed "s/[0-9]//" err >actual.err &&
20 sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
21 warning: GIT_INDEX_VERSION set, but the value is invalid.
24 test_cmp expect.err actual.err
28 test_expect_success
'out of bounds GIT_INDEX_VERSION issues warning' '
31 GIT_INDEX_VERSION=1 &&
32 export GIT_INDEX_VERSION &&
34 sed "s/[0-9]//" err >actual.err &&
35 sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
36 warning: GIT_INDEX_VERSION set, but the value is invalid.
39 test_cmp expect.err actual.err
43 test_expect_success
'no warning with bogus GIT_INDEX_VERSION and existing index' '
45 GIT_INDEX_VERSION=1 &&
46 export GIT_INDEX_VERSION &&
47 git add a 2>actual.err &&
48 test_must_be_empty actual.err
52 test_expect_success
'out of bounds index.version issues warning' '
54 sane_unset GIT_INDEX_VERSION &&
56 git config --add index.version 1 &&
58 sed "s/[0-9]//" err >actual.err &&
59 sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
60 warning: index.version set, but the value is invalid.
63 test_cmp expect.err actual.err
67 test_index_version
() {
68 INDEX_VERSION_CONFIG
=$1 &&
69 FEATURE_MANY_FILES
=$2 &&
71 EXPECTED_OUTPUT_VERSION
=$4 &&
75 if test "$INDEX_VERSION_CONFIG" -ne 0
77 git config
--add index.version
$INDEX_VERSION_CONFIG
79 git config
--add feature.manyFiles
$FEATURE_MANY_FILES
80 if test "$ENV_VAR_VERSION" -ne 0
82 GIT_INDEX_VERSION
=$ENV_VAR_VERSION &&
83 export GIT_INDEX_VERSION
85 unset GIT_INDEX_VERSION
88 echo $EXPECTED_OUTPUT_VERSION >expect
&&
89 test-tool index-version
<.git
/index
>actual
&&
90 test_cmp expect actual
94 test_expect_success
'index version config precedence' '
95 test_index_version 0 false 0 2 &&
96 test_index_version 2 false 0 2 &&
97 test_index_version 3 false 0 2 &&
98 test_index_version 4 false 0 4 &&
99 test_index_version 2 false 4 4 &&
100 test_index_version 2 true 0 2 &&
101 test_index_version 0 true 0 4 &&
102 test_index_version 0 true 2 2