]> git.ipfire.org Git - thirdparty/git.git/commitdiff
use local cloning if insteadOf makes a local URL
authorMichael Barabanov <michael.barabanov@windriver.com>
Thu, 17 Jul 2014 07:09:32 +0000 (00:09 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 Jul 2014 18:17:13 +0000 (11:17 -0700)
Move the is_local logic to the place where origin remote has been setup and
check if the remote url can be used to do local cloning.

This saves a lot of space (and time) in some of the mirroring scenarios that
involve insteadOf rewrites.

Signed-off-by: Michael Barabanov <michael.barabanov@windriver.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/clone.c

index f0dabecca88d8f16528fb68489e5b7a7700e2a47..bbd169ceb49b2e09197e469aeb572e9aa54d4b85 100644 (file)
@@ -799,18 +799,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
                die(_("repository '%s' does not exist"), repo_name);
        else
                repo = repo_name;
-       is_local = option_local != 0 && path && !is_bundle;
-       if (is_local) {
-               if (option_depth)
-                       warning(_("--depth is ignored in local clones; use file:// instead."));
-               if (!access(mkpath("%s/shallow", path), F_OK)) {
-                       if (option_local > 0)
-                               warning(_("source repository is shallow, ignoring --local"));
-                       is_local = 0;
-               }
-       }
-       if (option_local > 0 && !is_local)
-               warning(_("--local is ignored"));
 
        /* no need to be strict, transport_set_option() will validate it again */
        if (option_depth && atoi(option_depth) < 1)
@@ -903,6 +891,19 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
        remote = remote_get(option_origin);
        transport = transport_get(remote, remote->url[0]);
+       path = get_repo_path(remote->url[0], &is_bundle);
+       is_local = option_local != 0 && path && !is_bundle;
+       if (is_local) {
+               if (option_depth)
+                       warning(_("--depth is ignored in local clones; use file:// instead."));
+               if (!access(mkpath("%s/shallow", path), F_OK)) {
+                       if (option_local > 0)
+                               warning(_("source repository is shallow, ignoring --local"));
+                       is_local = 0;
+               }
+       }
+       if (option_local > 0 && !is_local)
+               warning(_("--local is ignored"));
        transport->cloning = 1;
 
        if (!transport->get_refs_list || (!is_local && !transport->fetch))