Fix --mirror option for init-repository

If submodule url is absolute, don't use mirror, don't set
remote.gerrit.url and remote.gerrit.fetch.

To avoid error when passing "--mirror git://github.com/qt/":
fatal: remote error: qt/https://code.qt.io/playground/qlitehtml
is not a valid repository name
Visit https://support.github.com/ for help

amends 7374ef8e38

Change-Id: Ifb4e1c8de57c7729f2965c16388f1acd763a150f
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
Li Xinwei
2021-05-31 17:45:52 +08:00
committed by Kai Koehne
parent 3b2dd1560c
commit 4450693ac0

View File

@@ -532,7 +532,7 @@ sub git_clone_one_submodule
}
my $mirror;
if ($mirror_url && ($do_clone || $self->{fetch})) {
if (!has_url_scheme($repo_basename) && $mirror_url && ($do_clone || $self->{fetch})) {
$mirror = $mirror_url.$repo_basename;
}
@@ -582,7 +582,9 @@ sub git_clone_one_submodule
$self->exe('git', 'config', 'commit.template', $template);
}
$self->git_add_remotes($repo_basename);
if (!has_url_scheme($repo_basename)) {
$self->git_add_remotes($repo_basename);
}
if ($self->{'detach-alternates'}) {
$self->exe('git', 'repack', '-a');