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
35 test_expect_code 1 git -C test2 config core.repositoryformatversion >actual
38 test_expect_success 'gitdir not required mode' '
39 git apply --stat test.patch &&
40 git -C test apply --stat ../test.patch &&
41 git -C test2 apply --stat ../test.patch
44 test_expect_success 'gitdir required mode' '
45 git apply --check --index test.patch &&
46 git -C test apply --check --index ../test.patch &&
47 test_must_fail git -C test2 apply --check --index ../test.patch
51 git rev-parse --git-dir >actual &&
53 test_cmp expect actual
57 test_must_fail git rev-parse --git-dir
60 # avoid git-config, since it cannot be trusted to run
61 # in a repository with a broken version
64 echo "repositoryformatversion = $1" &&
67 if test $# -gt 0; then
68 echo '[extensions]' &&
75 while read outcome version extensions; do
76 test_expect_success "$outcome version=$version $extensions" "
77 mkconfig $version $extensions >.git/config &&
84 abort 1 no-such-extension
85 allow 0 no-such-extension
88 test_expect_success 'precious-objects allowed' '
89 mkconfig 1 preciousObjects >.git/config &&
93 test_expect_success 'precious-objects blocks destructive repack' '
94 test_must_fail git repack -ad
97 test_expect_success 'other repacks are OK' '
102 test_expect_success 'precious-objects blocks prune' '
103 test_must_fail git prune
106 test_expect_success 'gc runs without complaint' '