aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-02-04 21:20:06 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-02-06 06:24:03 +0000
commit1ad0a17fa0068e5df8d0ccea2100936c583bc11e (patch)
tree798e67cb3df53fa24c360d89035cd77d408e841f
parentd553fc4fa9461b37b5275dcb556e3bdd1d93dedb (diff)
make manual fetching sane
it is in no way said that the remote's HEAD will contain the commit to be checked out - in fact, it's pretty much guaranteed that it won't for anything but the default branch. fetching the whole remote avoids additional roundtrips and makes the --branch feature actually work reasonably. Change-Id: I20de2da848b12aea8c5b2784307fe9860252009b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-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";