Skip to content

Commit 360822a

Browse files
pks-tgitster
authored andcommitted
builtin/clone: set up sparse checkout later
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9159029 commit 360822a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin/clone.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,9 +1185,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11851185
if (option_required_reference.nr || option_optional_reference.nr)
11861186
setup_reference();
11871187

1188-
if (option_sparse_checkout && git_sparse_checkout_init(dir))
1189-
return 1;
1190-
11911188
remote = remote_get(remote_name);
11921189

11931190
refspec_appendf(&remote->fetch, "+%s*:%s*", src_ref_prefix,
@@ -1426,6 +1423,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
14261423
dissociate_from_references();
14271424
}
14281425

1426+
if (option_sparse_checkout && git_sparse_checkout_init(dir))
1427+
return 1;
1428+
14291429
junk_mode = JUNK_LEAVE_REPO;
14301430
err = checkout(submodule_progress, filter_submodules);
14311431

0 commit comments

Comments
 (0)