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 promise_and_delete () {
17 HASH=$(git -C repo rev-parse "$1") &&
18 git -C repo tag -a -m message my_annotated_tag "$HASH" &&
19 git -C repo rev-parse my_annotated_tag | pack_as_from_promisor &&
20 git -C repo tag -d my_annotated_tag &&
21 delete_object repo "$HASH"
24 test_expect_success 'missing reflog object, but promised by a commit, passes fsck' '
25 test_create_repo repo &&
26 test_commit -C repo my_commit &&
28 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
29 C=$(git -C repo commit-tree -m c -p $A HEAD^{tree}) &&
31 # Reference $A only from reflog, and delete it
32 git -C repo branch my_branch "$A" &&
33 git -C repo branch -f my_branch my_commit &&
34 delete_object repo "$A" &&
36 # State that we got $C, which refers to $A, from promisor
37 printf "$C\n" | pack_as_from_promisor &&
40 test_must_fail git -C repo fsck &&
42 # But with the extension, it succeeds
43 git -C repo config core.repositoryformatversion 1 &&
44 git -C repo config extensions.partialclone "arbitrary string" &&
48 test_expect_success 'missing reflog object, but promised by a tag, passes fsck' '
50 test_create_repo repo &&
51 test_commit -C repo my_commit &&
53 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
54 git -C repo tag -a -m d my_tag_name $A &&
55 T=$(git -C repo rev-parse my_tag_name) &&
56 git -C repo tag -d my_tag_name &&
58 # Reference $A only from reflog, and delete it
59 git -C repo branch my_branch "$A" &&
60 git -C repo branch -f my_branch my_commit &&
61 delete_object repo "$A" &&
63 # State that we got $T, which refers to $A, from promisor
64 printf "$T\n" | pack_as_from_promisor &&
66 git -C repo config core.repositoryformatversion 1 &&
67 git -C repo config extensions.partialclone "arbitrary string" &&
71 test_expect_success 'missing reflog object alone fails fsck, even with extension set' '
73 test_create_repo repo &&
74 test_commit -C repo my_commit &&
76 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
77 B=$(git -C repo commit-tree -m b HEAD^{tree}) &&
79 # Reference $A only from reflog, and delete it
80 git -C repo branch my_branch "$A" &&
81 git -C repo branch -f my_branch my_commit &&
82 delete_object repo "$A" &&
84 git -C repo config core.repositoryformatversion 1 &&
85 git -C repo config extensions.partialclone "arbitrary string" &&
86 test_must_fail git -C repo fsck
89 test_expect_success 'missing ref object, but promised, passes fsck' '
91 test_create_repo repo &&
92 test_commit -C repo my_commit &&
94 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
96 # Reference $A only from ref
97 git -C repo branch my_branch "$A" &&
98 promise_and_delete "$A" &&
100 git -C repo config core.repositoryformatversion 1 &&
101 git -C repo config extensions.partialclone "arbitrary string" &&