blob: 5583f16db41fc9daeb0b2c17820e2b883f6cba6c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
#!/bin/sh
test_description='test across ref formats'
GIT_TEST_PACKED_REFS_VERSION=0
export GIT_TEST_PACKED_REFS_VERSION
. ./test-lib.sh
test_expect_success 'extensions.refFormat requires core.repositoryFormatVersion=1' '
test_when_finished rm -rf broken &&
# Force sha1 to ensure GIT_TEST_DEFAULT_HASH does
# not imply a value of core.repositoryFormatVersion.
git init --object-format=sha1 broken &&
git -C broken config extensions.refFormat files &&
test_must_fail git -C broken status 2>err &&
grep "repo version is 0, but v1-only extension found" err
'
test_expect_success 'invalid extensions.refFormat' '
test_when_finished rm -rf broken &&
git init broken &&
git -C broken config core.repositoryFormatVersion 1 &&
git -C broken config extensions.refFormat bogus &&
test_must_fail git -C broken status 2>err &&
grep "invalid value for '\''extensions.refFormat'\'': '\''bogus'\''" err
'
test_expect_success 'extensions.refFormat=packed only' '
git init only-packed &&
(
cd only-packed &&
git config core.repositoryFormatVersion 1 &&
git config extensions.refFormat packed &&
test_commit A &&
test_path_exists .git/packed-refs &&
test_path_is_missing .git/refs/tags/A
)
'
test_expect_success 'extensions.refFormat=files only' '
test_commit T &&
git pack-refs --all &&
git init only-loose &&
(
cd only-loose &&
git config core.repositoryFormatVersion 1 &&
git config extensions.refFormat files &&
test_commit A &&
test_commit B &&
test_must_fail git pack-refs 2>err &&
grep "refusing to create" err &&
test_path_is_missing .git/packed-refs &&
# Refuse to parse a packed-refs file.
cp ../.git/packed-refs .git/packed-refs &&
test_must_fail git rev-parse refs/tags/T
)
'
test_expect_success 'extensions.refFormat=files,packed-v2' '
test_commit Q &&
git pack-refs --all &&
git init no-packed-v1 &&
(
cd no-packed-v1 &&
git config core.repositoryFormatVersion 1 &&
git config extensions.refFormat files &&
git config --add extensions.refFormat packed-v2 &&
test_commit A &&
test_commit B &&
# Refuse to parse a v1 packed-refs file.
cp ../.git/packed-refs .git/packed-refs &&
test_must_fail git rev-parse refs/tags/Q &&
rm -f .git/packed-refs &&
git for-each-ref --format="%(refname) %(objectname)" >expect-all &&
git for-each-ref --format="%(refname) %(objectname)" \
refs/tags/* >expect-tags &&
# Create a v2 packed-refs file
git pack-refs --all &&
test_path_exists .git/packed-refs &&
for t in A B
do
test_path_is_missing .git/refs/tags/$t &&
git rev-parse refs/tags/$t || return 1
done &&
git for-each-ref --format="%(refname) %(objectname)" >actual-all &&
test_cmp expect-all actual-all &&
git for-each-ref --format="%(refname) %(objectname)" \
refs/tags/* >actual-tags &&
test_cmp expect-tags actual-tags
)
'
test_done
|