]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1600-index.sh
Merge branch 'en/merge-recursive-directory-rename-fixes'
[thirdparty/git.git] / t / t1600-index.sh
CommitLineData
136347d7
TG
1#!/bin/sh
2
3test_description='index file specific tests'
4
5. ./test-lib.sh
6
7test_expect_success 'setup' '
8 echo 1 >a
9'
10
11test_expect_success 'bogus GIT_INDEX_VERSION issues warning' '
12 (
13 rm -f .git/index &&
14 GIT_INDEX_VERSION=2bogus &&
15 export GIT_INDEX_VERSION &&
16 git add a 2>&1 | sed "s/[0-9]//" >actual.err &&
17 sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
18 warning: GIT_INDEX_VERSION set, but the value is invalid.
19 Using version Z
20 EOF
21 test_i18ncmp expect.err actual.err
22 )
23'
24
25test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' '
26 (
27 rm -f .git/index &&
28 GIT_INDEX_VERSION=1 &&
29 export GIT_INDEX_VERSION &&
30 git add a 2>&1 | sed "s/[0-9]//" >actual.err &&
31 sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
32 warning: GIT_INDEX_VERSION set, but the value is invalid.
33 Using version Z
34 EOF
35 test_i18ncmp expect.err actual.err
36 )
37'
38
39test_expect_success 'no warning with bogus GIT_INDEX_VERSION and existing index' '
40 (
41 GIT_INDEX_VERSION=1 &&
42 export GIT_INDEX_VERSION &&
43 git add a 2>actual.err &&
1c5e94f4 44 test_must_be_empty actual.err
136347d7
TG
45 )
46'
47
3c09d684
TG
48test_expect_success 'out of bounds index.version issues warning' '
49 (
50 sane_unset GIT_INDEX_VERSION &&
51 rm -f .git/index &&
52 git config --add index.version 1 &&
53 git add a 2>&1 | sed "s/[0-9]//" >actual.err &&
54 sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
55 warning: index.version set, but the value is invalid.
56 Using version Z
57 EOF
58 test_i18ncmp expect.err actual.err
59 )
60'
61
c6cc4c5a
DS
62test_index_version () {
63 INDEX_VERSION_CONFIG=$1 &&
64 FEATURE_MANY_FILES=$2 &&
65 ENV_VAR_VERSION=$3
66 EXPECTED_OUTPUT_VERSION=$4 &&
3c09d684
TG
67 (
68 rm -f .git/index &&
c6cc4c5a
DS
69 rm -f .git/config &&
70 if test "$INDEX_VERSION_CONFIG" -ne 0
71 then
72 git config --add index.version $INDEX_VERSION_CONFIG
73 fi &&
74 git config --add feature.manyFiles $FEATURE_MANY_FILES
75 if test "$ENV_VAR_VERSION" -ne 0
76 then
77 GIT_INDEX_VERSION=$ENV_VAR_VERSION &&
78 export GIT_INDEX_VERSION
79 else
80 unset GIT_INDEX_VERSION
81 fi &&
3c09d684 82 git add a 2>&1 &&
c6cc4c5a 83 echo $EXPECTED_OUTPUT_VERSION >expect &&
cc6f663d 84 test-tool index-version <.git/index >actual &&
3c09d684
TG
85 test_cmp expect actual
86 )
c6cc4c5a
DS
87}
88
89test_expect_success 'index version config precedence' '
c11e9966
DS
90 test_index_version 0 false 0 2 &&
91 test_index_version 2 false 0 2 &&
92 test_index_version 3 false 0 2 &&
93 test_index_version 4 false 0 4 &&
c6cc4c5a
DS
94 test_index_version 2 false 4 4 &&
95 test_index_version 2 true 0 2 &&
96 test_index_version 0 true 0 4 &&
97 test_index_version 0 true 2 2
3c09d684
TG
98'
99
136347d7 100test_done