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 &&
30 git config core.repositoryformatversion >../actual2
32 test_cmp expect actual &&
33 test_cmp expect actual2
36 test_expect_success 'gitdir selection on unsupported repo' '
37 # Make sure it would stop at test2, not trash
41 git config core.repositoryformatversion >../actual
43 test_cmp expect actual
46 test_expect_success 'gitdir not required mode' '
47 git apply --stat test.patch &&
50 git apply --stat ../test.patch
54 git apply --stat ../test.patch
58 test_expect_success 'gitdir required mode' '
59 git apply --check --index test.patch &&
62 git apply --check --index ../test.patch
66 test_must_fail git apply --check --index ../test.patch
71 git rev-parse --git-dir >actual &&
73 test_cmp expect actual
77 test_must_fail git rev-parse --git-dir
80 # avoid git-config, since it cannot be trusted to run
81 # in a repository with a broken version
84 echo "repositoryformatversion = $1" &&
87 if test $# -gt 0; then
88 echo '[extensions]' &&
95 while read outcome version extensions; do
96 test_expect_success "$outcome version=$version $extensions" "
97 mkconfig $version $extensions >.git/config &&
104 abort 1 no-such-extension
105 allow 0 no-such-extension
108 test_expect_success 'precious-objects allowed' '
109 mkconfig 1 preciousObjects >.git/config &&
113 test_expect_success 'precious-objects blocks destructive repack' '
114 test_must_fail git repack -ad
117 test_expect_success 'other repacks are OK' '
122 test_expect_success 'precious-objects blocks prune' '
123 test_must_fail git prune
126 test_expect_success 'gc runs without complaint' '