From ac6168c0cb00b32a644509645cb77e33470c4e2c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 4 Mar 2015 12:03:54 +0100 Subject: 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 --- init-repository | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/init-repository b/init-repository index 9a08406e..581d108e 100755 --- a/init-repository +++ b/init-repository @@ -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); } -- cgit v1.2.3