use git clone --branch instead of --no-checkout

git submodule update does not cause an actual checkout if HEAD matches
the recorded submodule sha1 even if it was not actually checked out.

it would be possible to work around this by calling git checkout HEAD in
each submodule if no files are checked out, but that seems hacky.

instead, just make the module cloning already check out the desired
branch. this produces checkouts that are within a few commits of the
final sha1, so isn't too bad.

Change-Id: I435c1a2e24f39fd8c0d65f0d90df0216715668b7
This commit is contained in:
Oswald Buddenhagen 2015-03-04 12:03:54 +01:00
parent be35b9f9af
commit ac6168c0cb
1 changed files with 4 additions and 3 deletions

View File

@ -383,7 +383,7 @@ sub git_clone_all_submodules
}
foreach my $module (@modules) {
$self->git_clone_one_submodule($subdirs{$module}, $subbases{$module});
$self->git_clone_one_submodule($subdirs{$module}, $subbases{$module}, $subbranches{$module});
}
if ($co_branch) {
@ -440,7 +440,7 @@ sub git_add_remotes
sub git_clone_one_submodule
{
my ($self, $submodule, $repo_basename) = @_;
my ($self, $submodule, $repo_basename, $branch) = @_;
my $alternates = $self->{ 'alternates' };
my $mirror_url = $self->{ 'mirror-url' };
@ -476,7 +476,8 @@ sub git_clone_one_submodule
my $do_clone = (! -e "$submodule/.git");
if ($do_clone) {
$self->exe('git', 'clone', '--no-checkout', @reference_args,
push @reference_args, '--branch', $branch if ($branch);
$self->exe('git', 'clone', @reference_args,
($mirror ? $mirror : $url), $submodule);
}