aboutsummaryrefslogtreecommitdiffstats
path: root/init-repository
diff options
context:
space:
mode:
Diffstat (limited to 'init-repository')
-rwxr-xr-xinit-repository13
1 files changed, 11 insertions, 2 deletions
diff --git a/init-repository b/init-repository
index b586110b..c6dd29b4 100755
--- a/init-repository
+++ b/init-repository
@@ -482,14 +482,23 @@ sub git_clone_one_submodule
my $orig_cwd = getcwd();
chdir($submodule) or confess "chdir $submodule: $OS_ERROR";
- $self->exe('git', 'config', 'remote.origin.url', $url);
if ($mirror) {
+ # This is only for the user's convenience - we make no use of it.
$self->exe('git', 'config', 'remote.mirror.url', $mirror);
$self->exe('git', 'config', 'remote.mirror.fetch', '+refs/heads/*:refs/remotes/mirror/*');
}
if (!$do_clone && $self->{update}) {
- $self->exe('git', 'fetch', ($mirror ? $mirror : $url));
+ # If we didn't clone, fetch from the right location. We always update
+ # the origin remote, so that submodule update --remote works.
+ $self->exe('git', 'config', 'remote.origin.url', ($mirror ? $mirror : $url));
+ $self->exe('git', 'fetch', 'origin');
+ }
+
+ if (!($do_clone || $self->{update}) || $mirror) {
+ # Leave the origin configured to the canonical URL. It's already correct
+ # if we cloned/fetched without a mirror; otherwise it may be anything.
+ $self->exe('git', 'config', 'remote.origin.url', $url);
}
my $template = getcwd()."/../.commit-template";