From d553fc4fa9461b37b5275dcb556e3bdd1d93dedb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Feb 2015 17:52:40 +0100 Subject: 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 --- init-repository | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'init-repository') diff --git a/init-repository b/init-repository index 6a7bd38e..b586110b 100755 --- a/init-repository +++ b/init-repository @@ -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; } -- cgit v1.2.3