Commit 7329bc7c authored by Asher Baker's avatar Asher Baker

Fix arc land on odd/modern git-svn checkouts

The current code assumes git-svn is always working from a remote called
`trunk`, but if the repository is initialized without the `-T` option it
will instead be called `git-svn`, and if `--prefix` is used (which is
set by default to `origin/` in Git 2+) the remote name will have the
specified prefix as well.

Instead, look at the `fetch` target refspec set in the git-svn config.

Fixes T13293.

Test Plan:
`arc land` without errors (or manually creating a `trunk` branch) from a
checkout made with Git 2.18.0 (verified this manually on a non-`-T`
checkout as well).

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Maniphest Tasks: T13293

Differential Revision:
parent dd514e26
......@@ -310,6 +310,33 @@ EOTEXT
return null;
private function getGitSvnTrunk() {
if (!$this->isGitSvn) {
return null;
// See T13293, this depends on the options passed when cloning.
// On any error we return `trunk`, which was the previous default.
$repository_api = $this->getRepositoryAPI();
list($err, $refspec) = $repository_api->execManualLocal(
'config svn-remote.svn.fetch');
if ($err) {
return 'trunk';
$refspec = rtrim(substr($refspec, strrpos($refspec, ':') + 1));
$prefix = 'refs/remotes/';
if (substr($refspec, 0, strlen($prefix)) !== $prefix) {
return 'trunk';
$refspec = substr($refspec, strlen($prefix));
return $refspec;
private function readEngineArguments() {
// NOTE: This is hard-coded for Git right now.
// TODO: Clean this up and move it into LandEngines.
......@@ -494,7 +521,7 @@ EOTEXT
$this->ontoRemoteBranch = $this->onto;
if ($this->isGitSvn) {
$this->ontoRemoteBranch = 'trunk';
$this->ontoRemoteBranch = $this->getGitSvnTrunk();
} else if ($this->isGit) {
$this->ontoRemoteBranch = $this->remote.'/'.$this->onto;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment