3 # Copyright (c) 2007 Nguyễn Thái Ngọc Duy
6 test_description
='Test repository version check'
8 TEST_PASSES_SANITIZE_LEAK
=true
11 test_expect_success
'setup' '
12 cat >test.patch <<-\EOF &&
13 diff --git a/test.txt b/test.txt
21 test_create_repo "test" &&
22 test_create_repo "test2" &&
23 git config --file=test2/.git/config core.repositoryformatversion 99
26 test_expect_success
'gitdir selection on normal repos' '
27 if test_have_prereq DEFAULT_REPO_FORMAT
33 git config core.repositoryformatversion >actual &&
34 git -C test config core.repositoryformatversion >actual2 &&
35 test_cmp expect actual &&
36 test_cmp expect actual2
39 test_expect_success
'gitdir selection on unsupported repo' '
40 # Make sure it would stop at test2, not trash
41 test_expect_code 1 git -C test2 config core.repositoryformatversion
44 test_expect_success
'gitdir not required mode' '
45 git apply --stat test.patch &&
46 git -C test apply --stat ../test.patch &&
47 git -C test2 apply --stat ../test.patch
50 test_expect_success
'gitdir required mode' '
51 git apply --check --index test.patch &&
52 git -C test apply --check --index ../test.patch &&
53 test_must_fail git -C test2 apply --check --index ../test.patch
57 git rev-parse
--git-dir >actual
&&
59 test_cmp expect actual
63 test_must_fail git rev-parse
--git-dir
66 # avoid git-config, since it cannot be trusted to run
67 # in a repository with a broken version
70 echo "repositoryformatversion = $1" &&
73 if test $# -gt 0; then
74 echo '[extensions]' &&
81 while read outcome version extensions
; do
82 test_expect_success
"$outcome version=$version $extensions" "
83 test_when_finished 'rm -rf extensions' &&
84 git init extensions &&
87 mkconfig $version $extensions >.git/config &&
95 abort
1 no-such-extension
96 allow
0 no-such-extension
102 test_expect_success
'precious-objects allowed' '
103 git config core.repositoryFormatVersion 1 &&
104 git config extensions.preciousObjects 1 &&
108 test_expect_success
'precious-objects blocks destructive repack' '
109 test_must_fail git repack -ad
112 test_expect_success
'other repacks are OK' '
117 test_expect_success
'precious-objects blocks prune' '
118 test_must_fail git prune
121 test_expect_success
'gc runs without complaint' '