3 # Copyright (c) 2007 Nguyễn Thái Ngọc Duy
6 test_description
='Test repository version check'
10 test_expect_success
'setup' '
11 cat >test.patch <<-\EOF &&
12 diff --git a/test.txt b/test.txt
20 test_create_repo "test" &&
21 test_create_repo "test2" &&
22 git config --file=test2/.git/config core.repositoryformatversion 99
25 test_expect_success
'gitdir selection on normal repos' '
27 git config core.repositoryformatversion >actual &&
28 git -C test config core.repositoryformatversion >actual2 &&
29 test_cmp expect actual &&
30 test_cmp expect actual2
33 test_expect_success
'gitdir selection on unsupported repo' '
34 # Make sure it would stop at test2, not trash
36 git -C test2 config core.repositoryformatversion >actual &&
37 test_cmp expect actual
40 test_expect_success
'gitdir not required mode' '
41 git apply --stat test.patch &&
42 git -C test apply --stat ../test.patch &&
43 git -C test2 apply --stat ../test.patch
46 test_expect_success
'gitdir required mode' '
47 git apply --check --index test.patch &&
48 git -C test apply --check --index ../test.patch &&
49 test_must_fail git -C test2 apply --check --index ../test.patch
53 git rev-parse
--git-dir >actual
&&
55 test_cmp expect actual
59 test_must_fail git rev-parse
--git-dir
62 # avoid git-config, since it cannot be trusted to run
63 # in a repository with a broken version
66 echo "repositoryformatversion = $1" &&
69 if test $# -gt 0; then
70 echo '[extensions]' &&
77 while read outcome version extensions
; do
78 test_expect_success
"$outcome version=$version $extensions" "
79 mkconfig $version $extensions >.git/config &&
86 abort
1 no-such-extension
87 allow
0 no-such-extension
90 test_expect_success
'precious-objects allowed' '
91 mkconfig 1 preciousObjects >.git/config &&
95 test_expect_success
'precious-objects blocks destructive repack' '
96 test_must_fail git repack -ad
99 test_expect_success
'other repacks are OK' '
104 test_expect_success
'precious-objects blocks prune' '
105 test_must_fail git prune
108 test_expect_success
'gc runs without complaint' '