]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/clone: set up sparse checkout later
authorPatrick Steinhardt <ps@pks.im>
Tue, 12 Dec 2023 07:00:59 +0000 (08:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Dec 2023 19:16:54 +0000 (11:16 -0800)
When asked to do a sparse checkout, then git-clone(1) will spawn
`git sparse-checkout set` to set up the configuration accordingly. This
requires a proper Git repository or otherwise the command will fail. But
as we are about to move creation of the reference database to a later
point, this prerequisite will not hold anymore.

Move the logic to a later point in time where we know to have created
the reference database already.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/clone.c

index d1886508819813e8e9c48d40163fbeb1041ec104..9c60923f31254616b8d26c6dab5e7de332215256 100644 (file)
@@ -1185,9 +1185,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        if (option_required_reference.nr || option_optional_reference.nr)
                setup_reference();
 
-       if (option_sparse_checkout && git_sparse_checkout_init(dir))
-               return 1;
-
        remote = remote_get(remote_name);
 
        refspec_appendf(&remote->fetch, "+%s*:%s*", src_ref_prefix,
@@ -1426,6 +1423,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                dissociate_from_references();
        }
 
+       if (option_sparse_checkout && git_sparse_checkout_init(dir))
+               return 1;
+
        junk_mode = JUNK_LEAVE_REPO;
        err = checkout(submodule_progress, filter_submodules);