Skip to content

Commit caba7fc

Browse files
jonathantanmygitster
authored andcommitted
fsck: support referenced promisor objects
Teach fsck to not treat missing promisor objects indirectly pointed to by refs as an error when extensions.partialclone is set. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 43f2515 commit caba7fc

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

builtin/fsck.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
149149
if (obj->flags & REACHABLE)
150150
return 0;
151151
obj->flags |= REACHABLE;
152+
153+
if (is_promisor_object(&obj->oid))
154+
/*
155+
* Further recursion does not need to be performed on this
156+
* object since it is a promisor object (so it does not need to
157+
* be added to "pending").
158+
*/
159+
return 0;
160+
152161
if (!(obj->flags & HAS_OBJ)) {
153162
if (parent && !has_object_file(&obj->oid)) {
154163
printf("broken link from %7s %s\n",
@@ -208,6 +217,8 @@ static void check_reachable_object(struct object *obj)
208217
* do a full fsck
209218
*/
210219
if (!(obj->flags & HAS_OBJ)) {
220+
if (is_promisor_object(&obj->oid))
221+
return;
211222
if (has_sha1_pack(obj->oid.hash))
212223
return; /* it is in pack - forget about it */
213224
printf("missing %s %s\n", printable_type(obj),

t/t0410-partial-clone.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,27 @@ test_expect_success 'missing ref object, but promised, passes fsck' '
102102
git -C repo fsck
103103
'
104104

105+
test_expect_success 'missing object, but promised, passes fsck' '
106+
rm -rf repo &&
107+
test_create_repo repo &&
108+
test_commit -C repo 1 &&
109+
test_commit -C repo 2 &&
110+
test_commit -C repo 3 &&
111+
git -C repo tag -a annotated_tag -m "annotated tag" &&
112+
113+
C=$(git -C repo rev-parse 1) &&
114+
T=$(git -C repo rev-parse 2^{tree}) &&
115+
B=$(git hash-object repo/3.t) &&
116+
AT=$(git -C repo rev-parse annotated_tag) &&
117+
118+
promise_and_delete "$C" &&
119+
promise_and_delete "$T" &&
120+
promise_and_delete "$B" &&
121+
promise_and_delete "$AT" &&
122+
123+
git -C repo config core.repositoryformatversion 1 &&
124+
git -C repo config extensions.partialclone "arbitrary string" &&
125+
git -C repo fsck
126+
'
127+
105128
test_done

0 commit comments

Comments
 (0)