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