summaryrefslogtreecommitdiffstats
path: root/init-repository
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2014-08-15 21:03:25 +0200
committerOswald Buddenhagen <oswald.buddenhagen@digia.com>2014-09-23 20:28:58 +0200
commit3ade7c4567eb00375a3670eb92a41ba979d5322c (patch)
tree267b7df969d51293fc2a53e6e7723f50353b6249 /init-repository
parent93f173b3c5143fa74e1bc3fa84d53ab0173f2b17 (diff)
rewrite submodule exclusion logic
instead of doing multiple passes over the submodules, do everything in one go. as a bonus, as the internal structure uses exclusion entries in the module list, we can make that feature user-accessible just as well. Change-Id: I8bfb30c8051a9150f92e2e124ff52f64e3efe03c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'init-repository')
-rwxr-xr-xinit-repository106
1 files changed, 39 insertions, 67 deletions
diff --git a/init-repository b/init-repository
index 9cafeb21..c38aff2e 100755
--- a/init-repository
+++ b/init-repository
@@ -99,6 +99,7 @@ Only initialize the specified subset of modules given as the argument. Specified
modules must already exist in .gitmodules.
The string "all" results in cloning all known modules. The default is the set of
maintained modules.
+Module names may be prefixed with a dash to exclude them from a bigger set.
=item --no-update
@@ -315,7 +316,7 @@ sub parse_arguments
'mirror-url' => "",
'update' => 1 ,
'webkit' => 1 ,
- 'module-subset' => join(",", @DEFAULT_REPOS),
+ 'module-subset' => "default",
);
GetOptionsFromArray(\@args,
@@ -344,12 +345,10 @@ sub parse_arguments
# Replace any double trailing slashes from end of mirror
$self->{'mirror-url'} =~ s{//+$}{/};
- if ($self->{'module-subset'} eq "all") {
- $self->{'module-subset'} = "";
- } else {
- $self->{'module-subset'} = {
- map { $_ => 1 } split(qr{,}, $self->{'module-subset'})
- };
+ $self->{'module-subset'} = [ map { $_ eq "default" ? (@DEFAULT_REPOS) : ($_) }
+ split(/,/, $self->{'module-subset'}) ];
+ if (!$self->{webkit}) {
+ push @{$self->{'module-subset'}}, "-qtwebkit", "-qtwebkit-examples";
}
return;
@@ -398,65 +397,49 @@ sub git_submodule_init
return;
}
-sub git_disable_webkit_submodule
-{
- my ($self) = @_;
-
- $self->exe('git', 'config', '--remove', 'submodule.qtwebkit');
- $self->exe('git', 'config', '--remove', 'submodule.qtwebkit-examples');
-
- return;
-}
-
-sub git_prune_submodules
+sub git_clone_all_submodules
{
- my ($self) = @_;
-
- my @configresult = qx(git config -l);
- foreach my $line (@configresult) {
- if ($line =~ /submodule\.([^.=]+)\.url=/) {
- my $module_name = $1;
- if (!$self->{'module-subset'}{$module_name}) {
- $self->exe('git', 'config', '--remove', "submodule.$module_name");
- }
+ my ($self, @subset) = @_;
+
+ my %include = ();
+ my %exclude = ();
+ my $include_all = 0;
+ foreach my $mod (@subset) {
+ if ($mod eq "all") {
+ $include_all = 1;
+ } elsif ($mod =~ s/^-//) {
+ $exclude{$mod} = 1;
+ } else {
+ $include{$mod} = 1;
}
}
-}
-
-sub git_set_submodule_config
-{
- my ($self) = @_;
- return unless ($self->{'ignore-submodules'});
+ $self->git_submodule_init;
- my @configresult = qx(git config -l);
+ # manually clone each repo here, so we can easily use reference repos, mirrors etc
+ my @configresult = qx(git config -l);
foreach my $line (@configresult) {
# Example line: submodule.qtqa.url=git://gitorious.org/qt/qtqa.git
next if ($line !~ /submodule\.([^.=]+)\.url=(.*)/);
+ my ($module, $url) = ($1, $2);
- $self->exe('git', 'config', "submodule.$1.ignore", 'all');
- }
-
- return;
-}
+ if (defined($exclude{$module}) || (!$include_all && !defined($include{$module}))) {
+ $self->exe('git', 'config', '--remove-section', "submodule.$module");
+ next;
+ }
-sub git_clone_all_submodules
-{
- my ($self) = @_;
+ if ($self->{'ignore-submodules'}) {
+ $self->exe('git', 'config', "submodule.$module.ignore", 'all');
+ }
- # manually clone each repo here, so we can easily use reference repos, mirrors etc
- my @configresult = qx(git config -l);
- foreach my $line (@configresult) {
- if ($line =~ /submodule\.([^.=]+)\.url=(.*)/) {
- $self->git_clone_one_submodule($1, $2);
- if ($1 eq "qtwebengine") {
- $self->exe('git', 'submodule', 'update', $1);
- my $orig_cwd = getcwd();
- chdir($1) or confess "chdir $1: $OS_ERROR";
- $self->exe('git', 'submodule', 'init');
- $self->git_clone_all_submodules;
- chdir("$orig_cwd") or confess "chdir $orig_cwd: $OS_ERROR";
- }
+ $self->git_clone_one_submodule($module, $url);
+ if ($module eq "qtwebengine") {
+ $self->exe('git', 'submodule', 'update', $module);
+ my $orig_cwd = getcwd();
+ chdir($module) or confess "chdir $module: $OS_ERROR";
+ $self->exe('git', 'submodule', 'init');
+ $self->git_clone_all_submodules("all");
+ chdir("$orig_cwd") or confess "chdir $orig_cwd: $OS_ERROR";
}
}
@@ -607,19 +590,8 @@ sub run
my ($self) = @_;
$self->check_if_already_initialized;
- $self->git_submodule_init;
-
- if (!$self->{webkit}) {
- $self->git_disable_webkit_submodule;
- }
-
- if ($self->{'module-subset'}) {
- $self->git_prune_submodules;
- }
-
- $self->git_set_submodule_config;
- $self->git_clone_all_submodules;
+ $self->git_clone_all_submodules(@{$self->{'module-subset'}});
$self->git_add_remotes('qt5');