To make it possible to have the external odb mechanism only kick in
after the initial part of a clone, we should disable it during the
initial part of the clone.

Let's do that by saving and then restoring the value of the
'use_external_odb' global variable.

Signed-off-by: Christian Couder <chrisc...@tuxfamily.org>
---
 builtin/clone.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/builtin/clone.c b/builtin/clone.c
index 57cecd194c..323b73016e 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -938,6 +938,7 @@ int cmd_clone(int argc, const char **argv, const char 
*prefix)
 
        struct refspec *initial_refspecs;
        int is_initial;
+       int saved_use_external_odb;
 
        packet_trace_identity("clone");
        argc = parse_options(argc, argv, prefix, builtin_clone_options,
@@ -1083,6 +1084,10 @@ int cmd_clone(int argc, const char **argv, const char 
*prefix)
 
        git_config(git_default_config, NULL);
 
+       /* Temporarily disable external ODB before initial clone */
+       saved_use_external_odb = use_external_odb;
+       use_external_odb = 0;
+
        if (option_bare) {
                if (option_mirror)
                        src_ref_prefix = "refs/";
@@ -1166,6 +1171,8 @@ int cmd_clone(int argc, const char **argv, const char 
*prefix)
                fetch_initial_refs(transport, refs, initial_refspecs,
                                   branch_top.buf, reflog_msg.buf, is_local);
 
+               use_external_odb = saved_use_external_odb;
+
                mapped_refs = wanted_peer_refs(refs, refspec);
                /*
                 * transport_get_remote_refs() may return refs with null sha-1
@@ -1207,6 +1214,9 @@ int cmd_clone(int argc, const char **argv, const char 
*prefix)
                                        option_branch, option_origin);
 
                warning(_("You appear to have cloned an empty repository."));
+
+               use_external_odb = saved_use_external_odb;
+
                mapped_refs = NULL;
                our_head_points_at = NULL;
                remote_head_points_at = NULL;
-- 
2.14.1.576.g3f707d88cd

Reply via email to