use local cloning if insteadOf makes a local URL
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>
Michael Barabanov committed
Jul 17, 2014 at 00:09 UTC
f38aa83f9a20765d4617c46283a13684597512e6
1 file changed
+13
-12
builtin/clone.c
+13
-12
@@ -799,18 +799,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
799
die(_("repository '%s' does not exist"), repo_name);
800
else
801
repo = repo_name;
802
- is_local = option_local != 0 && path && !is_bundle;
803
- if (is_local) {
804
- if (option_depth)
805
- warning(_("--depth is ignored in local clones; use file:// instead."));
806
- if (!access(mkpath("%s/shallow", path), F_OK)) {
807
- if (option_local > 0)
808
- warning(_("source repository is shallow, ignoring --local"));
809
- is_local = 0;
810
- }
811
- }
812
- if (option_local > 0 && !is_local)
813
- warning(_("--local is ignored"));
802
803
/* no need to be strict, transport_set_option() will validate it again */
804
if (option_depth && atoi(option_depth) < 1)
@@ -903,6 +891,19 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
891
892
remote = remote_get(option_origin);
893
transport = transport_get(remote, remote->url[0]);
894
+ path = get_repo_path(remote->url[0], &is_bundle);
895
+ is_local = option_local != 0 && path && !is_bundle;
896
+ if (is_local) {
897
+ if (option_depth)
898
+ warning(_("--depth is ignored in local clones; use file:// instead."));
899
+ if (!access(mkpath("%s/shallow", path), F_OK)) {
900
+ if (option_local > 0)
901
+ warning(_("source repository is shallow, ignoring --local"));
902
+ is_local = 0;
903
+ }
904
+ }
905
+ if (option_local > 0 && !is_local)
906
+ warning(_("--local is ignored"));
907
transport->cloning = 1;
908
909
if (!transport->get_refs_list || (!is_local && !transport->fetch))