]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix arc patch in git-svn repos
authorNick Harper <nharper@fb.com>
Fri, 27 Jan 2012 02:36:43 +0000 (18:36 -0800)
committerNick Harper <nharper@fb.com>
Fri, 27 Jan 2012 18:31:52 +0000 (10:31 -0800)
Summary:
Check that the base revision is a valid git ref before trying to create a branch
starting at that rev. When arc patch is used in a git repo using the git-svn
bridge, the base reversion is a uri for the svn rev, not a git ref.

Test Plan:
run arc patch on a git-svn repo, run it on a pure git repo, and verify it works
for both

Reviewers: epriestley, btrahan

CC: jungejason, aran, epriestley
Differential Revision: https://secure.phabricator.com/D1505

src/workflow/patch/ArcanistPatchWorkflow.php

index 41dcd693479dbe559e7c69381274c417320076ea..6e0dd8ce6e7e2ab8be3f78114df40b4bb0d755e2 100644 (file)
@@ -256,7 +256,16 @@ EOTEXT
     $repository_api = $this->getRepositoryAPI();
     $base_revision  = $bundle->getBaseRevision();
 
-    if ($base_revision) {
+    // verify the base revision is valid
+    // in a working copy that uses the git-svn bridge, the base revision might
+    // be a svn uri instead of a git ref
+    list($err) = exec_manual(
+      '(cd %s; git rev-parse --verify %s)',
+      $repository_api->getPath(),
+      $base_revision
+    );
+
+    if ($base_revision && !$err) {
       execx(
         '(cd %s; git checkout -b %s %s)',
         $repository_api->getPath(),