init-repository: avoid failure when combining `--force' and mirrors

Avoid a fatal error if the `mirror' remote already exists.

Reviewed-by: Sunil Thaha
Change-Id: Id6225fad265abb575f6f35f750ba7aed7729e0dc
This commit is contained in:
Rohan McGovern
2011-05-06 17:12:16 +10:00
parent 65ac36828a
commit caba93a9a6

View File

@@ -479,6 +479,13 @@ sub git_clone_one_submodule
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);
}