teach init-repository about branches

specifically, add the --branch option and the necessary keys to
.gitmodules.

Change-Id: I09e2df6bd012629f76a35238d66697637bdffe44
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
Oswald Buddenhagen
2014-11-10 18:08:58 +01:00
committed by Jani Heikkinen
parent e8053418e4
commit d5946d420f
2 changed files with 65 additions and 4 deletions

36
.gitmodules vendored
View File

@@ -1,139 +1,175 @@
[submodule "qtbase"] [submodule "qtbase"]
path = qtbase path = qtbase
url = ../qtbase.git url = ../qtbase.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtsvg"] [submodule "qtsvg"]
path = qtsvg path = qtsvg
url = ../qtsvg.git url = ../qtsvg.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtdeclarative"] [submodule "qtdeclarative"]
path = qtdeclarative path = qtdeclarative
url = ../qtdeclarative.git url = ../qtdeclarative.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtactiveqt"] [submodule "qtactiveqt"]
path = qtactiveqt path = qtactiveqt
url = ../qtactiveqt.git url = ../qtactiveqt.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtscript"] [submodule "qtscript"]
path = qtscript path = qtscript
url = ../qtscript.git url = ../qtscript.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtmultimedia"] [submodule "qtmultimedia"]
path = qtmultimedia path = qtmultimedia
url = ../qtmultimedia.git url = ../qtmultimedia.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qttools"] [submodule "qttools"]
path = qttools path = qttools
url = ../qttools.git url = ../qttools.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtxmlpatterns"] [submodule "qtxmlpatterns"]
path = qtxmlpatterns path = qtxmlpatterns
url = ../qtxmlpatterns.git url = ../qtxmlpatterns.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qttranslations"] [submodule "qttranslations"]
path = qttranslations path = qttranslations
url = ../qttranslations.git url = ../qttranslations.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtdoc"] [submodule "qtdoc"]
path = qtdoc path = qtdoc
url = ../qtdoc.git url = ../qtdoc.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtrepotools"] [submodule "qtrepotools"]
path = qtrepotools path = qtrepotools
url = ../qtrepotools.git url = ../qtrepotools.git
branch = master
initrepo = true initrepo = true
[submodule "qtwebkit"] [submodule "qtwebkit"]
path = qtwebkit path = qtwebkit
url = ../qtwebkit.git url = ../qtwebkit.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtwebkit-examples"] [submodule "qtwebkit-examples"]
path = qtwebkit-examples path = qtwebkit-examples
url = ../qtwebkit-examples.git url = ../qtwebkit-examples.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtqa"] [submodule "qtqa"]
path = qtqa path = qtqa
url = ../qtqa.git url = ../qtqa.git
branch = master
initrepo = true initrepo = true
[submodule "qtlocation"] [submodule "qtlocation"]
path = qtlocation path = qtlocation
url = ../qtlocation.git url = ../qtlocation.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtsensors"] [submodule "qtsensors"]
path = qtsensors path = qtsensors
url = ../qtsensors.git url = ../qtsensors.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtsystems"] [submodule "qtsystems"]
path = qtsystems path = qtsystems
url = ../qtsystems.git url = ../qtsystems.git
branch = dev
[submodule "qtfeedback"] [submodule "qtfeedback"]
path = qtfeedback path = qtfeedback
url = ../qtfeedback.git url = ../qtfeedback.git
branch = master
[submodule "qtdocgallery"] [submodule "qtdocgallery"]
path = qtdocgallery path = qtdocgallery
url = ../qtdocgallery.git url = ../qtdocgallery.git
branch = master
[submodule "qtpim"] [submodule "qtpim"]
path = qtpim path = qtpim
url = ../qtpim.git url = ../qtpim.git
branch = dev
[submodule "qtconnectivity"] [submodule "qtconnectivity"]
path = qtconnectivity path = qtconnectivity
url = ../qtconnectivity.git url = ../qtconnectivity.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtwayland"] [submodule "qtwayland"]
path = qtwayland path = qtwayland
url = ../qtwayland.git url = ../qtwayland.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qt3d"] [submodule "qt3d"]
path = qt3d path = qt3d
url = ../qt3d.git url = ../qt3d.git
branch = dev
[submodule "qtimageformats"] [submodule "qtimageformats"]
path = qtimageformats path = qtimageformats
url = ../qtimageformats.git url = ../qtimageformats.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtquick1"] [submodule "qtquick1"]
path = qtquick1 path = qtquick1
url = ../qtquick1.git url = ../qtquick1.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtgraphicaleffects"] [submodule "qtgraphicaleffects"]
path = qtgraphicaleffects path = qtgraphicaleffects
url = ../qtgraphicaleffects.git url = ../qtgraphicaleffects.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtquickcontrols"] [submodule "qtquickcontrols"]
path = qtquickcontrols path = qtquickcontrols
url = ../qtquickcontrols.git url = ../qtquickcontrols.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtserialport"] [submodule "qtserialport"]
path = qtserialport path = qtserialport
url = ../qtserialport.git url = ../qtserialport.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtx11extras"] [submodule "qtx11extras"]
path = qtx11extras path = qtx11extras
url = ../qtx11extras.git url = ../qtx11extras.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtmacextras"] [submodule "qtmacextras"]
path = qtmacextras path = qtmacextras
url = ../qtmacextras.git url = ../qtmacextras.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtwinextras"] [submodule "qtwinextras"]
path = qtwinextras path = qtwinextras
url = ../qtwinextras.git url = ../qtwinextras.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtandroidextras"] [submodule "qtandroidextras"]
path = qtandroidextras path = qtandroidextras
url = ../qtandroidextras.git url = ../qtandroidextras.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtenginio"] [submodule "qtenginio"]
path = qtenginio path = qtenginio
url = ../qtenginio.git url = ../qtenginio.git
branch = 1.1.0
initrepo = true initrepo = true
[submodule "qtwebsockets"] [submodule "qtwebsockets"]
path = qtwebsockets path = qtwebsockets
url = ../qtwebsockets.git url = ../qtwebsockets.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtwebchannel"] [submodule "qtwebchannel"]
path = qtwebchannel path = qtwebchannel
url = ../qtwebchannel.git url = ../qtwebchannel.git
branch = 5.4.0
initrepo = true initrepo = true
[submodule "qtwebengine"] [submodule "qtwebengine"]
path = qtwebengine path = qtwebengine
url = ../qtwebengine.git url = ../qtwebengine.git
branch = 5.4.0
initrepo = true initrepo = true

View File

@@ -105,6 +105,12 @@ Module names may be prefixed with a dash to exclude them from a bigger set.
Skip the `git submodule update' command. Skip the `git submodule update' command.
=item --branch
Instead of checking out specific SHA1s, check out the submodule branches that
correspond with the current supermodule commit.
By default, this option will cause local commits in the submodules to be rebased.
With --no-update, the branches will be checked out, but their heads will not move.
=item --ignore-submodules =item --ignore-submodules
@@ -233,6 +239,7 @@ sub parse_arguments
%{$self} = (%{$self}, %{$self} = (%{$self},
'alternates' => "", 'alternates' => "",
'branch' => 0,
'codereview-username' => "", 'codereview-username' => "",
'detach-alternates' => 0 , 'detach-alternates' => 0 ,
'force' => 0 , 'force' => 0 ,
@@ -246,6 +253,7 @@ sub parse_arguments
GetOptionsFromArray(\@args, GetOptionsFromArray(\@args,
'alternates=s' => \$self->{qw{ alternates }}, 'alternates=s' => \$self->{qw{ alternates }},
'branch' => \$self->{qw{ branch }},
'codereview-username=s' => \$self->{qw{ codereview-username }}, 'codereview-username=s' => \$self->{qw{ codereview-username }},
'copy-objects' => \$self->{qw{ detach-alternates }}, 'copy-objects' => \$self->{qw{ detach-alternates }},
'force|f' => \$self->{qw{ force }}, 'force|f' => \$self->{qw{ force }},
@@ -313,9 +321,10 @@ sub git_submodule_init
sub git_clone_all_submodules sub git_clone_all_submodules
{ {
my ($self, $my_repo_base, @subset) = @_; my ($self, $my_repo_base, $co_branch, @subset) = @_;
my %subdirs = (); my %subdirs = ();
my %subbranches = ();
my %subbases = (); my %subbases = ();
my %subinits = (); my %subinits = ();
my @submodconfig = qx(git config -l -f .gitmodules); my @submodconfig = qx(git config -l -f .gitmodules);
@@ -324,6 +333,8 @@ sub git_clone_all_submodules
next if ($line !~ /^submodule\.([^.=]+)\.([^.=]+)=(.*)$/); next if ($line !~ /^submodule\.([^.=]+)\.([^.=]+)=(.*)$/);
if ($2 eq "path") { if ($2 eq "path") {
$subdirs{$1} = $3; $subdirs{$1} = $3;
} elsif ($2 eq "branch") {
$subbranches{$1} = $3;
} elsif ($2 eq "url") { } elsif ($2 eq "url") {
my ($mod, $base) = ($1, $3); my ($mod, $base) = ($1, $3);
next if ($base !~ /^\.\.\//); next if ($base !~ /^\.\.\//);
@@ -376,16 +387,30 @@ sub git_clone_all_submodules
} }
if ($self->{update}) { if ($self->{update}) {
$self->exe('git', 'submodule', 'update'); $self->exe('git', 'submodule', 'update', ($co_branch ? ('--remote', '--rebase') : ()));
foreach my $module (@modules) { foreach my $module (@modules) {
if (-f $module.'/.gitmodules') { if (-f $module.'/.gitmodules') {
my $orig_cwd = getcwd(); my $orig_cwd = getcwd();
chdir($module) or confess "chdir $module: $OS_ERROR"; chdir($module) or confess "chdir $module: $OS_ERROR";
$self->git_clone_all_submodules($subbases{$module}, "all"); $self->git_clone_all_submodules($subbases{$module}, 0, "all");
chdir("$orig_cwd") or confess "chdir $orig_cwd: $OS_ERROR"; chdir("$orig_cwd") or confess "chdir $orig_cwd: $OS_ERROR";
} }
} }
} elsif ($co_branch) {
foreach my $module (@modules) {
my $branch = $subbranches{$module};
die("No branch defined for submodule $module.\n") if (!defined($branch));
my $orig_cwd = getcwd();
chdir($module) or confess "chdir $module: $OS_ERROR";
my $br = qx(git rev-parse -q --verify $branch);
if (!$br) {
$self->exe('git', 'checkout', '-b', $branch, "origin/$branch");
} else {
$self->exe('git', 'checkout', $branch);
}
chdir("$orig_cwd") or confess "chdir $orig_cwd: $OS_ERROR";
}
} }
return; return;
@@ -532,7 +557,7 @@ sub run
$url =~ s,qt/qt5$,,; $url =~ s,qt/qt5$,,;
$self->{'base-url'} = $url; $self->{'base-url'} = $url;
$self->git_clone_all_submodules('qt/qt5', @{$self->{'module-subset'}}); $self->git_clone_all_submodules('qt/qt5', $self->{branch}, @{$self->{'module-subset'}});
$self->git_add_remotes('qt/qt5'); $self->git_add_remotes('qt/qt5');