diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2016-11-25 20:03:24 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2016-11-30 15:12:07 +0000 |
commit | 977f0841e46f9a4249526f93cbfbf540210c76e6 (patch) | |
tree | 2b2f080627887801c38851424d961699161703dd /init-repository | |
parent | 75f605743cedbf897b8eb967f931458c4131d7b9 (diff) | |
download | qt5-977f0841e46f9a4249526f93cbfbf540210c76e6.tar.gz |
refuse to operate with dirty submodules
the operation would later error out anyway, after spending a lot of time
fetching the remotes, and leaving a partially updated state behind.
Change-Id: Ib2a688e446a9bd4ba3b15fc73082224433c18388
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'init-repository')
-rwxr-xr-x | init-repository | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/init-repository b/init-repository index 52efb201..5c76a31c 100755 --- a/init-repository +++ b/init-repository @@ -395,6 +395,14 @@ sub git_clone_all_submodules } } + my $any_bad = 0; + foreach my $module (@modules) { + $any_bad = 1 + if ($self->git_stat_one_submodule($subdirs{$module})); + } + die("Dirty submodule(s) present; cannot proceed.\n") + if ($any_bad); + foreach my $module (@modules) { $self->git_clone_one_submodule($subdirs{$module}, $subbases{$module}, $co_branch && $subbranches{$module}); @@ -452,6 +460,26 @@ sub git_add_remotes $self->exe('git', 'config', 'remote.gerrit.fetch', '+refs/heads/*:refs/remotes/gerrit/*', '/heads/'); } +sub git_stat_one_submodule +{ + my ($self, $submodule) = @_; + + return 0 if (! -e "$submodule/.git"); + + my $orig_cwd = getcwd(); + chdir($submodule) or confess "chdir $submodule: $OS_ERROR"; + + my @sts = qx(git status --porcelain --untracked=no); + + chdir($orig_cwd) or confess "cd $orig_cwd: $OS_ERROR"; + + return 0 if (!@sts); + + print STDERR "$submodule is dirty.\n"; + + return -1; +} + sub git_clone_one_submodule { my ($self, $submodule, $repo_basename, $branch) = @_; |