3 # Copyright (c) 2007 Nguyễn Thái Ngọc Duy
6 test_description='Test repository version check'
10 test_expect_success 'setup' '
11 test_oid_cache <<-\EOF &&
15 cat >test.patch <<-\EOF &&
16 diff --git a/test.txt b/test.txt
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
55 git rev-parse --git-dir >actual &&
57 test_cmp expect actual
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
68 echo "repositoryformatversion = $1" &&
71 if test $# -gt 0; then
72 echo '[extensions]' &&
79 while read outcome version extensions; do
80 test_expect_success "$outcome version=$version $extensions" "
81 mkconfig $version $extensions >.git/config &&
88 abort 1 no-such-extension
89 allow 0 no-such-extension
92 test_expect_success 'precious-objects allowed' '
93 mkconfig 1 preciousObjects >.git/config &&
97 test_expect_success 'precious-objects blocks destructive repack' '
98 test_must_fail git repack -ad
101 test_expect_success 'other repacks are OK' '
106 test_expect_success 'precious-objects blocks prune' '
107 test_must_fail git prune
110 test_expect_success 'gc runs without complaint' '