Page MenuHomePhabricator

`arc patch` fails to apply case-changing renames in git on Windows
Open, WishlistPublic

Description

$ arc patch --force D222
Created and checked out branch arcpatch-D222.
Checking patch Source/Installer/Installer.ism...
Checking patch Source/Installer/Script Files/Setup.Rul => Source/Installer/Script Files/Setup.rul...
error: Source/Installer/Script Files/Setup.rul: already exists in working directory
Applied patch Source/Installer/Installer.ism cleanly.

 Patch Failed!
Usage Exception: Unable to apply patch!

I understand that there's an underlying problem where git sucks at this on Windows all on its own, but arc complicates things by being case-sensitive internally even when the file system isn't:

$ git mv "Source/Installer/Script Files/Setup.Rul" tmp
$ git mv tmp "Source/Installer/Script Files/Setup.rul"
$ git commit -m "Just the rename"
[master 75c1116] Just the rename
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Source/Installer/Script Files/{Setup.Rul => Setup.rul} (100%)
$ arc patch --force --nobranch --trace D222
...
>>> [8] <exec> $ git show -s --format=%H "7e14f647cf7a194d8fd38c6c90dab282300bdb4d" --
<<< [8] <exec> 108,397 us
>>> [9] <exec> $ git branch --no-color
<<< [9] <exec> 107,420 us
>>> [10] <exec> $ git rev-parse --verify "arcpatch-D222"
<<< [10] <exec> 104,492 us
>>> [11] <exec> $ git show -s --format=%H "7e14f647cf7a194d8fd38c6c90dab282300bdb4d" --
<<< [11] <exec> 105,468 us
>>> [12] <exec> $ git checkout -b "arcpatch-D222" "7e14f647cf7a194d8fd38c6c90dab282300bdb4d"
<<< [12] <exec> 511,718 us

[2015-01-30 13:23:52] EXCEPTION: (CommandException) Command failed with error #1!
COMMAND
git checkout -b "arcpatch-D222" "7e14f647cf7a194d8fd38c6c90dab282300bdb4d"

STDOUT
(empty)

STDERR
error: The following untracked working tree files would be overwritten by checkout:
        Source/Installer/Script Files/Setup.Rul
Please move or remove them before you can switch branches.
Aborting
 at [<phutil>\src\future\exec\ExecFuture.php:397]
  #0 ExecFuture::resolvex() called at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:394]
  #1 ArcanistRepositoryAPI::execxLocal(string, string, string) called at [<arcanist>\src\workflow\ArcanistPatchWorkflow.php:290]
  #2 ArcanistPatchWorkflow::createBranch(ArcanistBundle, boolean) called at [<arcanist>\src\workflow\ArcanistPatchWorkflow.php:431]
  #3 ArcanistPatchWorkflow::run() called at [<arcanist>\src\workflow\ArcanistPatchWorkflow.php:375]
  #4 ArcanistPatchWorkflow::run() called at [<arcanist>\scripts\arcanist.php:364]
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean

Event Timeline

staticshock renamed this task from `arc patch` fails to apply case-changing renames on Windows to `arc patch` fails to apply case-changing renames in git on Windows.
staticshock raised the priority of this task from to Needs Triage.
staticshock updated the task description. (Show Details)
staticshock added a project: Arcanist.
staticshock added a subscriber: staticshock.
epriestley triaged this task as Wishlist priority.Jan 30 2015, 3:00 PM
epriestley added a subscriber: epriestley.

This is basically a Git problem and it's unlikely we can do anything about it.

It's possible you can fiddle with core.ignorecase in Git, or that we could detect and fiddle with it for you, but these operations are also just broken on OSX without any arc in the picture, and I routinely need to make these changes as separate commits when working with raw Git.

Mercurial also has issues here, for what it's worth, or did a while ago:

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'). Mercurial cannot ".
    "apply patches like this on case-insensitive filesystems. You ".
    "must apply this patch manually.\n"));

Here's a simple example of this fundamentally being a Git problem:

$ git mv file.c File.c
fatal: destination exists, source=file.c, destination=File.c