Merge branch 'jc/exclusion-doc'
[alt-git.git] / t / t1600-index.sh
blob079d2411450ca960d3d82fb9c7d59921c4cbe60a
1 #!/bin/sh
3 test_description='index file specific tests'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 echo 1 >a
11 test_expect_success 'bogus GIT_INDEX_VERSION issues warning' '
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
25 test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' '
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
39 test_expect_success 'no warning with bogus GIT_INDEX_VERSION and existing index' '
41 GIT_INDEX_VERSION=1 &&
42 export GIT_INDEX_VERSION &&
43 git add a 2>actual.err &&
44 >expect.err &&
45 test_i18ncmp expect.err actual.err
49 test_expect_success 'out of bounds index.version issues warning' '
51 sane_unset GIT_INDEX_VERSION &&
52 rm -f .git/index &&
53 git config --add index.version 1 &&
54 git add a 2>&1 | sed "s/[0-9]//" >actual.err &&
55 sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
56 warning: index.version set, but the value is invalid.
57 Using version Z
58 EOF
59 test_i18ncmp expect.err actual.err
63 test_expect_success 'GIT_INDEX_VERSION takes precedence over config' '
65 rm -f .git/index &&
66 GIT_INDEX_VERSION=4 &&
67 export GIT_INDEX_VERSION &&
68 git config --add index.version 2 &&
69 git add a 2>&1 &&
70 echo 4 >expect &&
71 test-index-version <.git/index >actual &&
72 test_cmp expect actual
76 test_done