Skip to content

Commit f38aa83

Browse files
michaelwrsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f2c9f21 commit f38aa83

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

builtin/clone.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -799,18 +799,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
799799
die(_("repository '%s' does not exist"), repo_name);
800800
else
801801
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"));
814802

815803
/* no need to be strict, transport_set_option() will validate it again */
816804
if (option_depth && atoi(option_depth) < 1)
@@ -903,6 +891,19 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
903891

904892
remote = remote_get(option_origin);
905893
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"));
906907
transport->cloning = 1;
907908

908909
if (!transport->get_refs_list || (!is_local && !transport->fetch))

0 commit comments

Comments
 (0)