fsck: support promisor objects as CLI argument

Teach fsck to not treat missing promisor objects provided on the CLI as an error when extensions.partialclone is set. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Dec 5, 2017 at 16:58 UTC 096c9b8be95ae18f78f6b4750b1d93c3cf9c8f05
2 files changed +15
builtin/fsck.c
+2
@@ -750,6 +750,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
750 struct object *obj = lookup_object(oid.hash);
751
752 if (!obj || !(obj->flags & HAS_OBJ)) {
753 + if (is_promisor_object(&oid))
754 + continue;
755 error("%s: object missing", oid_to_hex(&oid));
756 errors_found |= ERROR_OBJECT;
757 continue;
t/t0410-partial-clone.sh
+13
@@ -125,4 +125,17 @@ test_expect_success 'missing object, but promised, passes fsck' '
125 git -C repo fsck
126 '
127
128 +test_expect_success 'missing CLI object, but promised, passes fsck' '
129 + rm -rf repo &&
130 + test_create_repo repo &&
131 + test_commit -C repo my_commit &&
132 +
133 + A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
134 + promise_and_delete "$A" &&
135 +
136 + git -C repo config core.repositoryformatversion 1 &&
137 + git -C repo config extensions.partialclone "arbitrary string" &&
138 + git -C repo fsck "$A"
139 +'
140 +
141 test_done