]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1302-repo-version.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t1302-repo-version.sh
CommitLineData
9459aa77
NTND
1#!/bin/sh
2#
3# Copyright (c) 2007 Nguyễn Thái Ngọc Duy
4#
5
6test_description='Test repository version check'
7
8. ./test-lib.sh
9
8fe5aedd
JN
10test_expect_success 'setup' '
11 cat >test.patch <<-\EOF &&
12 diff --git a/test.txt b/test.txt
13 new file mode 100644
14 --- /dev/null
15 +++ b/test.txt
16 @@ -0,0 +1 @@
17 +123
18 EOF
9459aa77 19
8fe5aedd
JN
20 test_create_repo "test" &&
21 test_create_repo "test2" &&
f7e87141 22 git config --file=test2/.git/config core.repositoryformatversion 99
8fe5aedd 23'
9459aa77
NTND
24
25test_expect_success 'gitdir selection on normal repos' '
8fe5aedd
JN
26 echo 0 >expect &&
27 git config core.repositoryformatversion >actual &&
11ca4bec 28 git -C test config core.repositoryformatversion >actual2 &&
8fe5aedd
JN
29 test_cmp expect actual &&
30 test_cmp expect actual2
31'
9459aa77 32
9459aa77 33test_expect_success 'gitdir selection on unsupported repo' '
8fe5aedd 34 # Make sure it would stop at test2, not trash
b9605bc4 35 test_expect_code 1 git -C test2 config core.repositoryformatversion >actual
8fe5aedd 36'
9459aa77
NTND
37
38test_expect_success 'gitdir not required mode' '
fd4ec4f2 39 git apply --stat test.patch &&
11ca4bec
JK
40 git -C test apply --stat ../test.patch &&
41 git -C test2 apply --stat ../test.patch
18a82692 42'
9459aa77 43
8fe5aedd
JN
44test_expect_success 'gitdir required mode' '
45 git apply --check --index test.patch &&
11ca4bec
JK
46 git -C test apply --check --index ../test.patch &&
47 test_must_fail git -C test2 apply --check --index ../test.patch
41ac414e 48'
9459aa77 49
00a09d57
JK
50check_allow () {
51 git rev-parse --git-dir >actual &&
52 echo .git >expect &&
53 test_cmp expect actual
54}
55
56check_abort () {
57 test_must_fail git rev-parse --git-dir
58}
59
60# avoid git-config, since it cannot be trusted to run
61# in a repository with a broken version
62mkconfig () {
63 echo '[core]' &&
64 echo "repositoryformatversion = $1" &&
65 shift &&
66
67 if test $# -gt 0; then
68 echo '[extensions]' &&
69 for i in "$@"; do
70 echo "$i"
71 done
72 fi
73}
74
75while read outcome version extensions; do
76 test_expect_success "$outcome version=$version $extensions" "
77 mkconfig $version $extensions >.git/config &&
78 check_${outcome}
79 "
80done <<\EOF
81allow 0
82allow 1
83allow 1 noop
84abort 1 no-such-extension
85allow 0 no-such-extension
86EOF
87
067fbd41
JK
88test_expect_success 'precious-objects allowed' '
89 mkconfig 1 preciousObjects >.git/config &&
90 check_allow
91'
92
93test_expect_success 'precious-objects blocks destructive repack' '
94 test_must_fail git repack -ad
95'
96
97test_expect_success 'other repacks are OK' '
98 test_commit foo &&
99 git repack
100'
101
102test_expect_success 'precious-objects blocks prune' '
103 test_must_fail git prune
104'
105
106test_expect_success 'gc runs without complaint' '
107 git gc
108'
109
9459aa77 110test_done