My problem
-------------
I upgraded //Arcanist// recently and it broke my work flow considerably.
I have seen a few tickets about similar/related error but I figured I would create a new issue since my findings are most likely not perfect due to the fact that I am neither a //PHP// coder nor very versed with the platform differences between //Windows// and everything else.
escapeshellargs
-----------------
Anyway, the most evident issue is the wrongful transformation made by commands like this
```
execxLocal('log -1 --format=%s', '%H %ct');
```
On //Windows// the command that will be run is
```
git log -1 --format=" H ct"
```
And the output when running an arc command is something along these lines
```
[2015-07-10 09:31:06] EXCEPTION: (CommandException) Command failed with error #128!
COMMAND
git log -1 --format=" H ct"
STDOUT
(empty)
STDERR
fatal: invalid --pretty format: H ct
```
As noted already (by @epriestley) this is because of how `escapeshellargs` works, and that it replaces `%` (amongst others) with just a blank space.
(NOTE) Funny side not. When I started digging around for the cause of this problem I read "escapeshellargs" as "escape hell args" - which I think is appropriate for this situation actually :)
=== Fix
My fix for this was to change the line to the following
```
arcanist/src/workflow/ArcanistVersionWorkflow.php
54 list($stdout) = $repository->execxLocal('log -1 --format="%C"', '%H %ct');
```
This will output the correct format on Windows
```
git log -1 --format="%H %ct"
```
This should be cross platform safe since it //should//, to my understanding, output the same on OSX and Linux. However, I will leave it up to you to make that call and test it.
default root
-------------
The second issue I ran into was represented by the dreaded and very non-descriptive error message below. I have seen this error on many issues reported, but the cause of it seems to be very different on each of these issues (i.e. none of the issues I found did help me in finding this solution for this)
```
Usage Exception: `arc diff` is only supported under git, hg, svn.
```
Or with some more tracing, something along these lines
```
libphutil loaded from 'C:\Users\Martin\Arcanist\libphutil\src'.
arcanist loaded from 'C:\Users\Martin\Arcanist\arcanist\src'.
Config: Reading user configuration file "C:\Users\Martin\AppData\Roaming/.arcrc"...
Config: Did not find system configuration at "C:\ProgramData\Phabricator/Arcanist/config".
Working Copy: Reading .arcconfig from "C:\Users\Martin\Repositories\code/.arcconfig".
Working Copy: Path "C:\Users\Martin\Repositories\code" is part of `git` workingcopy "C:\Users\Martin\Repositories\code".
Working Copy: Project root is at "C:\Users\Martin\Repositories\code".
Config: Did not find local configuration at "C:\Users\Martin\Repositories\code\.git\arc/config".
>>> [0] <exec> $ where "git"
<<< [0] <exec> 68,539 us
Working Copy: No candidate locations for .arcconfig from this working directory.
Working Copy: Path "C:\Users\Martin\Arcanist\arcanist" is not in any working copy.
[2015-07-10 08:42:15] EXCEPTION: (Exception) The current working directory is not part of a working copy for a supported version control system (Git, Subversion or Mercurial). at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:82]
arcanist(head=master, ref.master=999eb9376568), phutil(head=master, ref.master=aa6cd8f7e5e5)
#0 ArcanistRepositoryAPI::newAPIFromConfigurationManager(ArcanistConfigurationManager) called at [<arcanist>\src\workflow\ArcanistVersionWorkflow.php:47]
#1 ArcanistVersionWorkflow::run() called at [<arcanist>\scripts\arcanist.php:382]
```
=== Shameful fix
The default value for root is represented by `\` in the code; but that will not work on //Windows//.
What I did was a super ugly hack and just changed it to `C:\` but a better solution would be to run the command `CD \` to get to the correct root directory (i.e. if you are on another drive than `C:`).
```
libphutil/src/filesystem/FileSystem.php
742 public static function walkToRoot($path, $root = 'C:/') {
```
What did this fix for me
--------------------------
At the time of writing I have only tested the `arc diff` and `arc land` command.
I will most likely also run `arc feature` soon and see if I run into any problems and can fix this in a similar fashion. But at least this is a start for those of us who think //Windows// is a valid platform to develop on and who love the //Phabricator// workflow.
Please try to make a fix for this. I know the problem of running //Arcanist// on //Windows// has been in the code for some weeks now, if not more, and it would be really appreciated if it was fixed so that those of us who is on //Windows// actually can be productive. I know we are few compared to the rest of the community but even a dirty fix for this would be OK (`phutil_is_windows()`).
Ref T8298, T8291, T6966