summaryrefslogtreecommitdiffstats
path: root/init-repository
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-11-09 17:38:49 +0100
committerQt by Nokia <qt-info@nokia.com>2011-11-11 17:14:02 +0100
commitc88e4747ad95cb679f16f36dcdb37812dbe634bb (patch)
treeafe449a5036f225ff49e693f3e79990b52c219f4 /init-repository
parent4cbe91304a5d1cbd26bffc0fb65333670a068de4 (diff)
always reconfigure all remotes
otherwise changing the user name or the remote type will be not be possible. Change-Id: I56a3790abbcf39cb4e75ac752af79581ed4c6e10 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'init-repository')
-rwxr-xr-xinit-repository41
1 files changed, 9 insertions, 32 deletions
diff --git a/init-repository b/init-repository
index 396b42ed..253d7fd4 100755
--- a/init-repository
+++ b/init-repository
@@ -513,14 +513,8 @@ sub git_add_remotes
{
my ($self, $repo_basename) = @_;
- my %current_remotes;
- for my $line (qx(git remote show)) {
- chomp $line;
- $current_remotes{$line} = 1;
- }
-
my $gerrit_repo_basename = $GERRIT_REPOS{$repo_basename};
- if ($gerrit_repo_basename && !$current_remotes{'gerrit'}) {
+ if ($gerrit_repo_basename) {
my $gerrit_repo_url;
# If given a username, make a "verbose" remote.
@@ -536,19 +530,8 @@ sub git_add_remotes
}
$gerrit_repo_url .= $gerrit_repo_basename;
- $self->exe('git', 'remote', 'add', 'gerrit', $gerrit_repo_url);
-
- $current_remotes{'gerrit'} = 1;
- }
-
- # if repo still has no gerrit repo defined, alias it to origin
- if (!$current_remotes{'gerrit'}) {
- my @configresult = qx(git remote -v);
- foreach (@configresult) {
- if (/^origin\s+(\S+) \(fetch\)/) {
- $self->exe('git', 'remote', 'add', 'gerrit', $1);
- }
- }
+ $self->exe('git', 'config', 'remote.gerrit.url', $gerrit_repo_url);
+ $self->exe('git', 'config', 'remote.gerrit.fetch', '+refs/heads/*:refs/remotes/gerrit/*');
}
return;
@@ -593,6 +576,12 @@ sub git_clone_one_submodule
chdir($submodule) or confess "chdir $submodule: $OS_ERROR";
+ $self->exe('git', 'config', 'remote.origin.url', $url);
+ if ($mirror) {
+ $self->exe('git', 'config', 'remote.mirror.url', $mirror);
+ $self->exe('git', 'config', 'remote.mirror.fetch', '+refs/heads/*:refs/remotes/mirror/*');
+ }
+
if (!$do_clone) {
$self->exe('git', 'fetch', ($mirror ? $mirror : $url));
}
@@ -602,18 +591,6 @@ sub git_clone_one_submodule
$self->exe('git', 'config', 'commit.template', $template);
}
- if ($mirror) {
- $self->exe('git', 'config', 'remote.origin.url', $url);
-
- # In `force' mode, remove the mirror if it already exists,
- # since we may be reinitializing the module.
- if ($self->{force}) {
- eval { $self->exe('git', 'remote', 'rm', 'mirror'); }; # failure is OK
- }
-
- $self->exe('git', 'remote', 'add', 'mirror', $mirror);
- }
-
$self->git_add_remotes($submodule);
if ($self->{'detach-alternates'}) {