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 test_oid_cache <<-\EOF &&
16 cat >test.patch <<-\EOF &&
17 diff --git a/test.txt b/test.txt
25 test_create_repo "test" &&
26 test_create_repo "test2" &&
27 git config --file=test2/.git/config core.repositoryformatversion 99
30 test_expect_success
'gitdir selection on normal repos' '
31 test_oid version >expect &&
32 git config core.repositoryformatversion >actual &&
33 git -C test config core.repositoryformatversion >actual2 &&
34 test_cmp expect actual &&
35 test_cmp expect actual2
38 test_expect_success
'gitdir selection on unsupported repo' '
39 # Make sure it would stop at test2, not trash
40 test_expect_code 1 git -C test2 config core.repositoryformatversion
43 test_expect_success
'gitdir not required mode' '
44 git apply --stat test.patch &&
45 git -C test apply --stat ../test.patch &&
46 git -C test2 apply --stat ../test.patch
49 test_expect_success
'gitdir required mode' '
50 git apply --check --index test.patch &&
51 git -C test apply --check --index ../test.patch &&
52 test_must_fail git -C test2 apply --check --index ../test.patch
56 git rev-parse
--git-dir >actual
&&
58 test_cmp expect actual
62 test_must_fail git rev-parse
--git-dir
65 # avoid git-config, since it cannot be trusted to run
66 # in a repository with a broken version
69 echo "repositoryformatversion = $1" &&
72 if test $# -gt 0; then
73 echo '[extensions]' &&
80 while read outcome version extensions
; do
81 test_expect_success
"$outcome version=$version $extensions" "
82 mkconfig $version $extensions >.git/config &&
89 abort
1 no-such-extension
90 allow
0 no-such-extension
96 test_expect_success
'precious-objects allowed' '
97 mkconfig 1 preciousObjects >.git/config &&
101 test_expect_success
'precious-objects blocks destructive repack' '
102 test_must_fail git repack -ad
105 test_expect_success
'other repacks are OK' '
110 test_expect_success
'precious-objects blocks prune' '
111 test_must_fail git prune
114 test_expect_success
'gc runs without complaint' '