always check out the target branch when using --branch

a submodule update with --remote will use the tip of the remote's
branch, but it won't actually switch to the branch if HEAD doesn't point
to it yet.

Change-Id: If13e31da2646683dfb9e832eaab929190acb0167
Reviewed-by: Sergio Ahumada <sahumada@texla.cl>
This commit is contained in:
Oswald Buddenhagen
2015-02-03 17:52:40 +01:00
committed by Simon Hausmann
parent b236ef6aef
commit d553fc4fa9

View File

@@ -386,20 +386,7 @@ sub git_clone_all_submodules
$self->git_clone_one_submodule($subdirs{$module}, $subbases{$module});
}
if ($self->{update}) {
my @cmd = ('git', 'submodule', 'update');
push @cmd, '--remote', '--rebase' if ($co_branch);
$self->exe(@cmd);
foreach my $module (@modules) {
if (-f $module.'/.gitmodules') {
my $orig_cwd = getcwd();
chdir($module) or confess "chdir $module: $OS_ERROR";
$self->git_clone_all_submodules($subbases{$module}, 0, "all");
chdir("$orig_cwd") or confess "chdir $orig_cwd: $OS_ERROR";
}
}
} elsif ($co_branch) {
if ($co_branch) {
foreach my $module (@modules) {
my $branch = $subbranches{$module};
die("No branch defined for submodule $module.\n") if (!defined($branch));
@@ -414,6 +401,20 @@ sub git_clone_all_submodules
chdir("$orig_cwd") or confess "chdir $orig_cwd: $OS_ERROR";
}
}
if ($self->{update}) {
my @cmd = ('git', 'submodule', 'update');
push @cmd, '--remote', '--rebase' if ($co_branch);
$self->exe(@cmd);
foreach my $module (@modules) {
if (-f $module.'/.gitmodules') {
my $orig_cwd = getcwd();
chdir($module) or confess "chdir $module: $OS_ERROR";
$self->git_clone_all_submodules($subbases{$module}, 0, "all");
chdir("$orig_cwd") or confess "chdir $orig_cwd: $OS_ERROR";
}
}
}
return;
}