parse-options: document bracketing of argh
[git/debian.git] / t / t1600-index.sh
blob46329c488b19cd41759d78c6d89a4411d193402e
1 #!/bin/sh
3 test_description='index file specific tests'
5 . ./test-lib.sh
7 sane_unset GIT_TEST_SPLIT_INDEX
9 test_expect_success 'setup' '
10 echo 1 >a
13 test_expect_success 'bogus GIT_INDEX_VERSION issues warning' '
15 rm -f .git/index &&
16 GIT_INDEX_VERSION=2bogus &&
17 export GIT_INDEX_VERSION &&
18 git add a 2>err &&
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.
22 Using version Z
23 EOF
24 test_cmp expect.err actual.err
28 test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' '
30 rm -f .git/index &&
31 GIT_INDEX_VERSION=1 &&
32 export GIT_INDEX_VERSION &&
33 git add a 2>err &&
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.
37 Using version Z
38 EOF
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 &&
55 rm -f .git/index &&
56 git config --add index.version 1 &&
57 git add a 2>err &&
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.
61 Using version Z
62 EOF
63 test_cmp expect.err actual.err
67 test_index_version () {
68 INDEX_VERSION_CONFIG=$1 &&
69 FEATURE_MANY_FILES=$2 &&
70 ENV_VAR_VERSION=$3
71 EXPECTED_OUTPUT_VERSION=$4 &&
73 rm -f .git/index &&
74 rm -f .git/config &&
75 if test "$INDEX_VERSION_CONFIG" -ne 0
76 then
77 git config --add index.version $INDEX_VERSION_CONFIG
78 fi &&
79 git config --add feature.manyFiles $FEATURE_MANY_FILES
80 if test "$ENV_VAR_VERSION" -ne 0
81 then
82 GIT_INDEX_VERSION=$ENV_VAR_VERSION &&
83 export GIT_INDEX_VERSION
84 else
85 unset GIT_INDEX_VERSION
86 fi &&
87 git add a &&
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
105 test_done