Page MenuHomePhabricator

`arc land` using git-svn fails in certain configurations
Closed, ResolvedPublic

Description

arc land looks for a ref called trunk when landing, which is created by the -T option to git svn clone (if the -T option is not used, the ref is called git-svn).

Additionally, git-svn supports putting its refs under a prefix, and as of Git 2.x the default has changed to use a prefix of origin/ to be aligned with other git functionality, which results in the ref being called origin/trunk which arc land also fails to find.

In either of these cases, running arc land will error with:

[2019-05-20 11:22:44] EXCEPTION: (CommandException) Command failed with error #128!
COMMAND
git log 'trunk'..'master'

STDOUT
(empty)

STDERR
fatal: ambiguous argument 'trunk..master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
 at [<phutil>/src/future/exec/ExecFuture.php:380]
arcanist(head=master, ref.master=82445bb60534), phutil(head=master, ref.master=c175590464bd)
  #0 ExecFuture::resolvex() called at [<arcanist>/src/repository/api/ArcanistRepositoryAPI.php:406]
  #1 ArcanistRepositoryAPI::execxLocal(string, string, string) called at [<arcanist>/src/workflow/ArcanistLandWorkflow.php:834]
  #2 ArcanistLandWorkflow::pullFromRemote() called at [<arcanist>/src/workflow/ArcanistLandWorkflow.php:256]
  #3 ArcanistLandWorkflow::run() called at [<arcanist>/scripts/arcanist.php:394]
arcanist 82445bb6053451f3a6221c3d2c2f3bce50ea5871 (15 May 2019)
libphutil c175590464bd24a8785535a325dc08c938189e9e (20 May 2019)

STR are kind of a pain, the rSVNTEST repo here doesn't use a standard layout (and neither does our monorepo really) and creating full diff is required, so I created a new repo with the following layout matching ours to test with.

.
├── branches
├── tags
└── trunk
    ├── project_one
    │   └── README.md
    └── project_two
        └── README.md

When working with this using SVN we'd checkout a subpath under trunk/ directly, i.e.

svn co svn+ssh://git@code.tripleplay-services.com/source/svn-test/trunk/project_one

Here are the 3 tests I did checking this out with git-svn (using --prefix to emulate Git 2.x):

WORKING: Checkout the repository root with the trunk subpath specified
git svn clone svn+ssh://git@code.tripleplay-services.com/source/svn-test/ -T trunk/project_one git_project_one_root_with_T

BROKEN: Full path as the repository URL
git svn clone svn+ssh://git@code.tripleplay-services.com/source/svn-test/trunk/project_one git_project_one_full_path

BROKEN: Using --prefix / Git 2.x and -T
git svn clone svn+ssh://git@code.tripleplay-services.com/source/svn-test/ -T trunk/project_one --prefix 'origin/' git_project_one_with_prefix

After creating these clones, branch, commit, diff, land as with using git normally - using the following as the diff base revision respectively: trunk, git-svn, origin/trunk.
As an aside, it would be nice for Arcanist to use the same logic from (fixed) arc land to suggest these as it can be difficult for users to figure out.

I've included full commands and output from each of these below, including the refs and git config, first doing a clone and diff/land with arc patched with D19681 showing it working (mainly because I was a plum and forgot my local copy was patched and wanted to preserve chronological order), then again with the 3 doing a pull and another diff/land using current master arcanist showing the error above.

All of this should repro against rSVNTEST here, you'd just need to pick one of the folders to be your "trunk".

[root@TPS-POR-ASHER1 arc-git-svn-test]# git svn clone svn+ssh://git@code.tripleplay-services.com/source/svn-test/ -T trunk/project_one git_project_one_root_with_T
Initialized empty Git repository in /root/arc-git-svn-test/git_project_one_root_with_T/.git/
        A       README.md
r2 = 7d436e20ce44a5599dfa7335936391033a9d0d6b (refs/remotes/trunk)
Checked out HEAD:
  svn+ssh://git@code.tripleplay-services.com/source/svn-test/trunk/project_one r2

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# git show-ref
7d436e20ce44a5599dfa7335936391033a9d0d6b refs/heads/master
7d436e20ce44a5599dfa7335936391033a9d0d6b refs/remotes/trunk

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[svn-remote "svn"]
        url = svn+ssh://git@code.tripleplay-services.com/source/svn-test
        fetch = trunk/project_one:refs/remotes/trunk

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# cat .git/arc/default-relative-commit
trunk

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# git checkout -b test-branch-one
Switched to a new branch 'test-branch-one'

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# vim README.md

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# git commit -a
[test-branch-one e9c91ce] Add line to readme
 1 file changed, 1 insertion(+)

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# arc --config 'repository.callsign=SVNTEST' diff
Linting...
No lint engine configured for this project.
Running unit tests...
No unit test engine is configured for this project.
 SKIP STAGING  Phabricator does not support staging areas for this repository.
Updating commit message...
Created a new Differential revision:
        Revision URI: https://code.tripleplay-services.com/D3485

Included changes:
  M       README.md

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# arc --config 'repository.callsign=SVNTEST' land
Landing current branch 'test-branch-one'.
Switched to branch master. Updating branch...
The following commit(s) will be landed:

9322a53 Add line to readme

Switched to branch test-branch-one. Identifying and merging...
Landing revision 'D3485: Add line to readme'...
 BUILDS PASSED  Harbormaster builds for the active diff completed successfully.
Pushing change...

Committing to svn+ssh://git@code.tripleplay-services.com/source/svn-test/trunk/project_one ...
        M       README.md
Committed r4
        M       README.md
r4 = cb499c03bfbaaeda6cc5fa660ba47df9246948a0 (refs/remotes/trunk)
No changes between 7beacc74d89043845785536481afa4caa35448e2 and refs/remotes/trunk
Resetting to the latest refs/remotes/trunk

Cleaning up feature branch...
(Use `git checkout -b 'test-branch-one' '9322a531bde8325e086b9258e857d678621ddb41'` if you want it back.)
Done.
[root@TPS-POR-ASHER1 arc-git-svn-test]# git svn clone svn+ssh://git@code.tripleplay-services.com/source/svn-test/trunk/project_one git_project_one_full_path
Initialized empty Git repository in /root/arc-git-svn-test/git_project_one_full_path/.git/
        A       README.md
r2 = 7d436e20ce44a5599dfa7335936391033a9d0d6b (refs/remotes/git-svn)
        M       README.md
r4 = cb499c03bfbaaeda6cc5fa660ba47df9246948a0 (refs/remotes/git-svn)
Checked out HEAD:
  svn+ssh://git@code.tripleplay-services.com/source/svn-test/trunk/project_one r4

[root@TPS-POR-ASHER1 git_project_one_full_path]# git show-ref
cb499c03bfbaaeda6cc5fa660ba47df9246948a0 refs/heads/master
cb499c03bfbaaeda6cc5fa660ba47df9246948a0 refs/remotes/git-svn

[root@TPS-POR-ASHER1 git_project_one_full_path]# cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[svn-remote "svn"]
        url = svn+ssh://git@code.tripleplay-services.com/source/svn-test/trunk/project_one
        fetch = :refs/remotes/git-svn

[root@TPS-POR-ASHER1 git_project_one_full_path]# cat .git/arc/default-relative-commit
git-svn

[root@TPS-POR-ASHER1 git_project_one_full_path]# git checkout -b change-two
Switched to a new branch 'change-two'

[root@TPS-POR-ASHER1 git_project_one_full_path]# vim README.md

[root@TPS-POR-ASHER1 git_project_one_full_path]# git commit -a
[change-two cc1ce89] Add another line to README
 1 file changed, 1 insertion(+)

[root@TPS-POR-ASHER1 git_project_one_full_path]# arc --config 'repository.callsign=SVNTEST' diff
Linting...
No lint engine configured for this project.
Running unit tests...
No unit test engine is configured for this project.
 SKIP STAGING  Phabricator does not support staging areas for this repository.
Updating commit message...
Created a new Differential revision:
        Revision URI: https://code.tripleplay-services.com/D3486

Included changes:
  M       README.md

[root@TPS-POR-ASHER1 git_project_one_full_path]# arc --config 'repository.callsign=SVNTEST' land
Landing current branch 'change-two'.
Switched to branch master. Updating branch...
The following commit(s) will be landed:

ed90769 Add another line to README

Switched to branch change-two. Identifying and merging...
Landing revision 'D3486: Add another line to README'...
 BUILDS PASSED  Harbormaster builds for the active diff completed successfully.
Pushing change...

Committing to svn+ssh://git@code.tripleplay-services.com/source/svn-test/trunk/project_one ...
        M       README.md
Committed r5
        M       README.md
r5 = 5b869129aa63bc3cbd1c259c8489471f67c0ba78 (refs/remotes/git-svn)
No changes between f895078b5f032e10a41bb25c4a7398ed66953d6b and refs/remotes/git-svn
Resetting to the latest refs/remotes/git-svn

Cleaning up feature branch...
(Use `git checkout -b 'change-two' 'ed90769d18c2817e9e378cdb211094478700c5da'` if you want it back.)
Done.
[root@TPS-POR-ASHER1 arc-git-svn-test]# git svn clone svn+ssh://git@code.tripleplay-services.com/source/svn-test/ -T trunk/project_one --prefix 'origin/' git_project_one_with_prefix
Initialized empty Git repository in /root/arc-git-svn-test/git_project_one_with_prefix/.git/
        A       README.md
r2 = 7d436e20ce44a5599dfa7335936391033a9d0d6b (refs/remotes/origin/trunk)
        M       README.md
r4 = cb499c03bfbaaeda6cc5fa660ba47df9246948a0 (refs/remotes/origin/trunk)
        M       README.md
r5 = 5b869129aa63bc3cbd1c259c8489471f67c0ba78 (refs/remotes/origin/trunk)
Checked out HEAD:
  svn+ssh://git@code.tripleplay-services.com/source/svn-test/trunk/project_one r5

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# git show-ref
5b869129aa63bc3cbd1c259c8489471f67c0ba78 refs/heads/master
5b869129aa63bc3cbd1c259c8489471f67c0ba78 refs/remotes/origin/trunk

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[svn-remote "svn"]
        url = svn+ssh://git@code.tripleplay-services.com/source/svn-test
        fetch = trunk/project_one:refs/remotes/origin/trunk

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# cat .git/arc/default-relative-commit
origin/trunk

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# git checkout -b change-three
Switched to a new branch 'change-three'

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# vim README.md

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# git commit -a
[change-three b546ef5] Add yet another line to README
 1 file changed, 1 insertion(+)

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# arc --config 'repository.callsign=SVNTEST' diff
Linting...
No lint engine configured for this project.
Running unit tests...
No unit test engine is configured for this project.
 SKIP STAGING  Phabricator does not support staging areas for this repository.
Updating commit message...
Created a new Differential revision:
        Revision URI: https://code.tripleplay-services.com/D3488

Included changes:
  M       README.md

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# arc --config 'repository.callsign=SVNTEST' land
Landing current branch 'change-three'.
Switched to branch master. Updating branch...
The following commit(s) will be landed:

51c7ae0 Add yet another line to README

Switched to branch change-three. Identifying and merging...
Landing revision 'D3488: Add yet another line to README'...
 BUILDS PASSED  Harbormaster builds for the active diff completed successfully.
Pushing change...

Committing to svn+ssh://git@code.tripleplay-services.com/source/svn-test/trunk/project_one ...
        M       README.md
Committed r6
        M       README.md
r6 = 67fbc476c36398f627ab0d97e22b83bd041df829 (refs/remotes/origin/trunk)
No changes between 8e1c6bb1b9461716aae91714f0520fd1903c6b78 and refs/remotes/origin/trunk
Resetting to the latest refs/remotes/origin/trunk

Cleaning up feature branch...
(Use `git checkout -b 'change-three' '51c7ae0537d4e4219ff6cf9533457187fac6d9ce'` if you want it back.)
Done.

Upstream arc follows.

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# git svn fetch
        M       README.md
r5 = 5b869129aa63bc3cbd1c259c8489471f67c0ba78 (refs/remotes/trunk)
        M       README.md
r6 = 67fbc476c36398f627ab0d97e22b83bd041df829 (refs/remotes/trunk)

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# git svn rebase
First, rewinding head to replay your work on top of it...
Fast-forwarded master to refs/remotes/trunk.

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# git checkout -b change-four
Switched to a new branch 'change-four'

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# vim README.md

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# git commit -a
[change-four f4d9a6f] Add another line.
 1 file changed, 1 insertion(+)

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# ../arcanist/bin/arc --config 'repository.callsign=SVNTEST' diff
Linting...
No lint engine configured for this project.
Running unit tests...
No unit test engine is configured for this project.
 SKIP STAGING  Phabricator does not support staging areas for this repository.
Updating commit message...
Created a new Differential revision:
        Revision URI: https://code.tripleplay-services.com/D3491

Included changes:
  M       README.md

[root@TPS-POR-ASHER1 git_project_one_root_with_T]# ../arcanist/bin/arc --config 'repository.callsign=SVNTEST' land
Landing current branch 'change-four'.
Switched to branch master. Updating branch...
The following commit(s) will be landed:

fc5e3f7 Add another line.

Switched to branch change-four. Identifying and merging...
Landing revision 'D3491: Add another line.'...
 BUILDS  Checking build status...
Pushing change...

Committing to svn+ssh://git@code.tripleplay-services.com/source/svn-test/trunk/project_one ...
        M       README.md
Committed r7
        M       README.md
r7 = 3a4353b28e9e85a05d2a84232762aaeea0f5cace (refs/remotes/trunk)
No changes between 62aa2530a744472303dbad7204c1e2f8c3bfac2f and refs/remotes/trunk
Resetting to the latest refs/remotes/trunk

Cleaning up feature branch...
(Use `git checkout -b 'change-four' 'fc5e3f7277c475872ee7bcb7edfce8ad55ce78b4'` if you want it back.)
Done.
[root@TPS-POR-ASHER1 git_project_one_full_path]# git svn fetch
        M       README.md
r6 = 67fbc476c36398f627ab0d97e22b83bd041df829 (refs/remotes/git-svn)
        M       README.md
r7 = 3a4353b28e9e85a05d2a84232762aaeea0f5cace (refs/remotes/git-svn)

[root@TPS-POR-ASHER1 git_project_one_full_path]# git svn rebase
First, rewinding head to replay your work on top of it...
Fast-forwarded master to refs/remotes/git-svn.

[root@TPS-POR-ASHER1 git_project_one_full_path]# git checkout -b change-five
Switched to a new branch 'change-five'

[root@TPS-POR-ASHER1 git_project_one_full_path]# vim README.md

[root@TPS-POR-ASHER1 git_project_one_full_path]# git commit -a
[change-five 1efa832] Maybe it's another line?
 1 file changed, 1 insertion(+)

[root@TPS-POR-ASHER1 git_project_one_full_path]# ../arcanist/bin/arc --config 'repository.callsign=SVNTEST' diff
Linting...
No lint engine configured for this project.
Running unit tests...
No unit test engine is configured for this project.
 SKIP STAGING  Phabricator does not support staging areas for this repository.
Updating commit message...
Created a new Differential revision:
        Revision URI: https://code.tripleplay-services.com/D3492

Included changes:
  M       README.md

[root@TPS-POR-ASHER1 git_project_one_full_path]# ../arcanist/bin/arc --config 'repository.callsign=SVNTEST' land
Landing current branch 'change-five'.
Switched to branch master. Updating branch...
Switched back to branch change-five.
 Exception
Command failed with error #128!
COMMAND
git log 'trunk'..'master'

STDOUT
(empty)

STDERR
fatal: ambiguous argument 'trunk..master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

(Run with `--trace` for a full exception trace.)
[root@TPS-POR-ASHER1 git_project_one_with_prefix]# git svn fetch
        M       README.md
r7 = 3a4353b28e9e85a05d2a84232762aaeea0f5cace (refs/remotes/origin/trunk)

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# git svn rebase
First, rewinding head to replay your work on top of it...
Fast-forwarded master to refs/remotes/origin/trunk.

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# git checkout -b change-six
Switched to a new branch 'change-six'

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# vim README.md

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# git commit -a
[change-six 395564c] Still more lines.
 1 file changed, 1 insertion(+)

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# ../arcanist/bin/arc --config 'repository.callsign=SVNTEST' diff
Linting...
No lint engine configured for this project.
Running unit tests...
No unit test engine is configured for this project.
 SKIP STAGING  Phabricator does not support staging areas for this repository.
Updating commit message...
Created a new Differential revision:
        Revision URI: https://code.tripleplay-services.com/D3493

Included changes:
  M       README.md

[root@TPS-POR-ASHER1 git_project_one_with_prefix]# ../arcanist/bin/arc --config 'repository.callsign=SVNTEST' land
Landing current branch 'change-six'.
Switched to branch master. Updating branch...
Switched back to branch change-six.
 Exception
Command failed with error #128!
COMMAND
git log 'trunk'..'master'

STDOUT
(empty)

STDERR
fatal: ambiguous argument 'trunk..master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

(Run with `--trace` for a full exception trace.)