From: jungejason Date: Sat, 24 Dec 2011 07:48:46 +0000 (-0800) Subject: Use getcwd() which is more reliable than $_SERVER['PWD'] X-Git-Tag: conduit-4~206 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6910fd77a4e34bc9e5b1953ee0a9457dbe3dedb8;p=arcanist.git Use getcwd() which is more reliable than $_SERVER['PWD'] Summary: in arcanist we are using $_SERVER['PWD'], but in some cases it is not returning the correct result. For example, when I'm using PhpStorm (an php IDE) to launch the script, $_SERVER['PWD'] returns the path of the binary of the IDE: /home/jungejason/tools/PhpStorm-107.658/bin, not the path where arcanist is at. getcwd() returns the correct value. One difference between getcwd() and $_SERVER['PWD'] is that getcwd() resolves symlink where $_SERVER['PWD'] does not. From what I can see, using realpath should work. Test Plan: * ran arcanist as normal and it worked; * run arcanist in PhpStorm and it worked. * created a symlink pointing to the repository inside which I ran the arc command, and it worked. * created a symlink pointing to arcanist project, run `. * resources/shell/bash-completion` and it worked Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1285 --- diff --git a/scripts/arcanist.php b/scripts/arcanist.php index 23b06dc0..1ef7f431 100755 --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -63,7 +63,7 @@ if (function_exists('posix_isatty') && !posix_isatty(STDOUT)) { } $args = array_values($args); -$working_directory = $_SERVER['PWD']; +$working_directory = getcwd(); try { diff --git a/src/workflow/shell-complete/ArcanistShellCompleteWorkflow.php b/src/workflow/shell-complete/ArcanistShellCompleteWorkflow.php index 238e2dd7..fa185391 100644 --- a/src/workflow/shell-complete/ArcanistShellCompleteWorkflow.php +++ b/src/workflow/shell-complete/ArcanistShellCompleteWorkflow.php @@ -64,7 +64,7 @@ EOTEXT // We have to build our own because if we requiresWorkingCopy() we'll throw // if we aren't in a .arcconfig directory. We probably still can't do much, // but commands can raise more detailed errors. - $working_copy = ArcanistWorkingCopyIdentity::newFromPath($_SERVER['PWD']); + $working_copy = ArcanistWorkingCopyIdentity::newFromPath(getcwd()); if ($working_copy->getProjectRoot()) { $repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity( $working_copy);