diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-08-06 14:03:14 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@gmx.de> | 2021-08-13 07:23:14 +0000 |
commit | 47b15af0dab2650902501e497fc4481a1eef9060 (patch) | |
tree | aa0e0c5309faa05c0c3b94a25d3af12aa1644f1c | |
parent | e85982c40f35906a832d81f2326f10b0207d6008 (diff) | |
download | qtrepotools-47b15af0dab2650902501e497fc4481a1eef9060.tar.gz |
gpush/gpick: Use resolved Gerrit URL for both pushing and fetching changes
The user might have set up a remote with a separate push URL, e.g.:
[url "git://code.qt.io/"]
insteadOf = qt-project:
[url "ssh://codereview.qt-project.org/"]
pushInsteadOf = qt-project:
We resolve the Gerrit URL and host in set_gerrit_config(), by taking
insteadOf and pushInsteadOf into account. By using the resolved URL
instead of the remote name when fetching we ensure that we always hit
the Gerrit server. Without this git-gpick will fail.
Change-Id: I580f01b8615c9d9fe5961036b8bb260ef62c8261
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
-rwxr-xr-x | bin/git-gpick | 2 | ||||
-rwxr-xr-x | bin/git-gpush | 2 | ||||
-rw-r--r-- | bin/git_gpush.pm | 3 |
3 files changed, 5 insertions, 2 deletions
diff --git a/bin/git-gpick b/bin/git-gpick index 31c427a..b964820 100755 --- a/bin/git-gpick +++ b/bin/git-gpick @@ -1085,7 +1085,7 @@ sub fetch_patchsets($$;$) my @gitcmd = ("git", "fetch"); # The git-fetch output is quite noisy and unhelpful here, unless debugging. push @gitcmd, '-q' if (!$debug); - push @gitcmd, $remote, @refs; + push @gitcmd, $gerrit_url, @refs; run_process(FWD_OUTPUT, @gitcmd); if (!$fetched_upstream) { $fetched_upstream = 1; diff --git a/bin/git-gpush b/bin/git-gpush index a0884af..8fd7d67 100755 --- a/bin/git-gpush +++ b/bin/git-gpush @@ -1812,7 +1812,7 @@ sub push_fragment($$) push @gitcmd, '-q' if ($quiet); push @gitcmd, '-n' if ($dry_run); push @gitcmd, map { ("-o", "$_") } @push_options; - push @gitcmd, $remote, "$tip:refs/for/$to"; + push @gitcmd, $gerrit_url, "$tip:refs/for/$to"; run_process(FWD_OUTPUT, @gitcmd); } diff --git a/bin/git_gpush.pm b/bin/git_gpush.pm index b8a38b8..9a8ff9b 100644 --- a/bin/git_gpush.pm +++ b/bin/git_gpush.pm @@ -2156,6 +2156,8 @@ sub _update_target_branches($) # gerrit ssh handling # ####################### +# URL for pushing/fetching from the Gerrit instance. +our $gerrit_url; # SSH arguments for connecting the Gerrit instance. our @gerrit_ssh; # Target repository name on the Gerrit instance. @@ -2170,6 +2172,7 @@ sub set_gerrit_config($) $url = git_config('remote.'.$rmt.'.url') if (!$url); fail("Remote '$rmt' does not exist.\n") if (!$url); $url = _rewrite_git_push_url($url); + $gerrit_url = $url; if ($url =~ m,^ssh://([^/:]+)(?::(\d+))?/(.*?)(?:\.git)?/?$,) { push @gerrit_ssh, '-p', $2 if (defined($2)); push @gerrit_ssh, $1; |