]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Raise a better error message when "arc patch" fails because of filename case changes
authorepriestley <git@epriestley.com>
Mon, 26 Mar 2012 16:43:37 +0000 (09:43 -0700)
committerepriestley <git@epriestley.com>
Mon, 26 Mar 2012 16:43:37 +0000 (09:43 -0700)
Summary: Git can't apply filename case change patches on case-insensitive filesystems. Some day we could manually do this ourselves, but it's fairly rare and complicated -- just raise a useful warning.

Test Plan: Tried to apply a case-changing patch, got a good error.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, epriestley
Maniphest Tasks: T618

Differential Revision: https://secure.phabricator.com/D2015

src/workflow/patch/ArcanistPatchWorkflow.php

index f5b97579491dbf4f11e00717d4881526423b503c..49d87512df414145dddb62e5f074fbab6ab2fd71 100644 (file)
@@ -581,7 +581,24 @@ EOTEXT
       $future = $repository_api->execFutureLocal(
         'apply --index --reject');
       $future->write($bundle->toGitPatch());
-      $future->resolvex();
+
+      try {
+        $future->resolvex();
+      } catch (CommandException $ex) {
+        echo phutil_console_format(
+          "\n<bg:red>** Patch Failed! **</bg>\n");
+        $stderr = $ex->getStdErr();
+        if (preg_match('/already exists in working directory/', $stderr)) {
+          echo phutil_console_wrap(
+            phutil_console_format(
+              "\n<bg:yellow>** WARNING **</bg> This patch may have failed ".
+              "because it attempts to change the case of a filename (for ".
+              "instance, from 'example.c' to 'Example.c'). Git can not apply ".
+              "patches like this on case-insensitive filesystems. You must ".
+              "apply this patch manually.\n"));
+        }
+        throw $ex;
+      }
 
       if ($this->shouldCommit()) {
         $commit_message = $this->getCommitMessage($bundle);