fsck: support promisor objects as CLI argument
authorJonathan Tan <jonathantanmy@google.com>
Tue, 5 Dec 2017 16:58:47 +0000 (16:58 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Dec 2017 17:46:05 +0000 (09:46 -0800)
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>
builtin/fsck.c
t/t0410-partial-clone.sh
index 4c2a56d0c2aba78eed7234aee600e52f16bdd275..578a7c8b0835842c8b1e3e1661401cb71c69432b 100644 (file)
@@ -750,6 +750,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
                        struct object *obj = lookup_object(oid.hash);
 
                        if (!obj || !(obj->flags & HAS_OBJ)) {
+                               if (is_promisor_object(&oid))
+                                       continue;
                                error("%s: object missing", oid_to_hex(&oid));
                                errors_found |= ERROR_OBJECT;
                                continue;
index 4f9931f9bbd98f21fe8b4c9ddc5f343d7dee8807..e96f436b09b5d3f838edafc347d1a7d362c577a9 100755 (executable)
@@ -125,4 +125,17 @@ test_expect_success 'missing object, but promised, passes fsck' '
        git -C repo fsck
 '
 
+test_expect_success 'missing CLI object, but promised, passes fsck' '
+       rm -rf repo &&
+       test_create_repo repo &&
+       test_commit -C repo my_commit &&
+
+       A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
+       promise_and_delete "$A" &&
+
+       git -C repo config core.repositoryformatversion 1 &&
+       git -C repo config extensions.partialclone "arbitrary string" &&
+       git -C repo fsck "$A"
+'
+
 test_done