From caba93a9a672e575e8621d0b4a8b5800769794e9 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 6 May 2011 17:12:16 +1000 Subject: [PATCH] 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 --- init-repository | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/init-repository b/init-repository index df3cf5f9..423fc856 100755 --- a/init-repository +++ b/init-repository @@ -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); }