Fourth batch
[git/raj.git] / t / t1302-repo-version.sh
blob0acabb6d11b48aca54e73025965f4c4e6b561d34
1 #!/bin/sh
3 # Copyright (c) 2007 Nguyễn Thái Ngọc Duy
6 test_description='Test repository version check'
8 . ./test-lib.sh
10 test_expect_success 'setup' '
11 test_oid_cache <<-\EOF &&
12 version sha1:0
13 version sha256:1
14 EOF
15 cat >test.patch <<-\EOF &&
16 diff --git a/test.txt b/test.txt
17 new file mode 100644
18 --- /dev/null
19 +++ b/test.txt
20 @@ -0,0 +1 @@
21 +123
22 EOF
24 test_create_repo "test" &&
25 test_create_repo "test2" &&
26 git config --file=test2/.git/config core.repositoryformatversion 99
29 test_expect_success 'gitdir selection on normal repos' '
30 echo $(test_oid version) >expect &&
31 git config core.repositoryformatversion >actual &&
32 git -C test config core.repositoryformatversion >actual2 &&
33 test_cmp expect actual &&
34 test_cmp expect actual2
37 test_expect_success 'gitdir selection on unsupported repo' '
38 # Make sure it would stop at test2, not trash
39 test_expect_code 1 git -C test2 config core.repositoryformatversion >actual
42 test_expect_success 'gitdir not required mode' '
43 git apply --stat test.patch &&
44 git -C test apply --stat ../test.patch &&
45 git -C test2 apply --stat ../test.patch
48 test_expect_success 'gitdir required mode' '
49 git apply --check --index test.patch &&
50 git -C test apply --check --index ../test.patch &&
51 test_must_fail git -C test2 apply --check --index ../test.patch
54 check_allow () {
55 git rev-parse --git-dir >actual &&
56 echo .git >expect &&
57 test_cmp expect actual
60 check_abort () {
61 test_must_fail git rev-parse --git-dir
64 # avoid git-config, since it cannot be trusted to run
65 # in a repository with a broken version
66 mkconfig () {
67 echo '[core]' &&
68 echo "repositoryformatversion = $1" &&
69 shift &&
71 if test $# -gt 0; then
72 echo '[extensions]' &&
73 for i in "$@"; do
74 echo "$i"
75 done
79 while read outcome version extensions; do
80 test_expect_success "$outcome version=$version $extensions" "
81 mkconfig $version $extensions >.git/config &&
82 check_${outcome}
84 done <<\EOF
85 allow 0
86 allow 1
87 allow 1 noop
88 abort 1 no-such-extension
89 allow 0 no-such-extension
90 allow 0 noop
91 abort 0 noop-v1
92 allow 1 noop-v1
93 EOF
95 test_expect_success 'precious-objects allowed' '
96 mkconfig 1 preciousObjects >.git/config &&
97 check_allow
100 test_expect_success 'precious-objects blocks destructive repack' '
101 test_must_fail git repack -ad
104 test_expect_success 'other repacks are OK' '
105 test_commit foo &&
106 git repack
109 test_expect_success 'precious-objects blocks prune' '
110 test_must_fail git prune
113 test_expect_success 'gc runs without complaint' '
114 git gc
117 test_done