3 test_description
='partial clone'
8 rm $1/.git
/objects
/$
(echo $2 |
sed -e 's|^..|&/|')
11 pack_as_from_promisor
() {
12 HASH
=$
(git
-C repo pack-objects .git
/objects
/pack
/pack
) &&
13 >repo
/.git
/objects
/pack
/pack-
$HASH.promisor
16 test_expect_success
'missing reflog object, but promised by a commit, passes fsck' '
17 test_create_repo repo &&
18 test_commit -C repo my_commit &&
20 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
21 C=$(git -C repo commit-tree -m c -p $A HEAD^{tree}) &&
23 # Reference $A only from reflog, and delete it
24 git -C repo branch my_branch "$A" &&
25 git -C repo branch -f my_branch my_commit &&
26 delete_object repo "$A" &&
28 # State that we got $C, which refers to $A, from promisor
29 printf "$C\n" | pack_as_from_promisor &&
32 test_must_fail git -C repo fsck &&
34 # But with the extension, it succeeds
35 git -C repo config core.repositoryformatversion 1 &&
36 git -C repo config extensions.partialclone "arbitrary string" &&
40 test_expect_success
'missing reflog object, but promised by a tag, passes fsck' '
42 test_create_repo repo &&
43 test_commit -C repo my_commit &&
45 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
46 git -C repo tag -a -m d my_tag_name $A &&
47 T=$(git -C repo rev-parse my_tag_name) &&
48 git -C repo tag -d my_tag_name &&
50 # Reference $A only from reflog, and delete it
51 git -C repo branch my_branch "$A" &&
52 git -C repo branch -f my_branch my_commit &&
53 delete_object repo "$A" &&
55 # State that we got $T, which refers to $A, from promisor
56 printf "$T\n" | pack_as_from_promisor &&
58 git -C repo config core.repositoryformatversion 1 &&
59 git -C repo config extensions.partialclone "arbitrary string" &&
63 test_expect_success
'missing reflog object alone fails fsck, even with extension set' '
65 test_create_repo repo &&
66 test_commit -C repo my_commit &&
68 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
69 B=$(git -C repo commit-tree -m b HEAD^{tree}) &&
71 # Reference $A only from reflog, and delete it
72 git -C repo branch my_branch "$A" &&
73 git -C repo branch -f my_branch my_commit &&
74 delete_object repo "$A" &&
76 git -C repo config core.repositoryformatversion 1 &&
77 git -C repo config extensions.partialclone "arbitrary string" &&
78 test_must_fail git -C repo fsck