diff --git a/src/applications/diffusion/query/branch/git/DiffusionGitBranchQuery.php b/src/applications/diffusion/query/branch/git/DiffusionGitBranchQuery.php index f9306577b9..4dfb46ad8f 100644 --- a/src/applications/diffusion/query/branch/git/DiffusionGitBranchQuery.php +++ b/src/applications/diffusion/query/branch/git/DiffusionGitBranchQuery.php @@ -24,9 +24,8 @@ final class DiffusionGitBranchQuery extends DiffusionBranchQuery { $local_path = $repository->getDetail('local-path'); - list($stdout) = execx( - '(cd %s && git branch -r --verbose --no-abbrev)', - $local_path); + list($stdout) = $repository->execxLocalCommand( + 'branch -r --verbose --no-abbrev'); $branches = array(); foreach (self::parseGitRemoteBranchOutput($stdout) as $name => $head) { diff --git a/src/applications/diffusion/query/branch/git/__init__.php b/src/applications/diffusion/query/branch/git/__init__.php index 025d906a8b..2e621c8c50 100644 --- a/src/applications/diffusion/query/branch/git/__init__.php +++ b/src/applications/diffusion/query/branch/git/__init__.php @@ -9,7 +9,5 @@ phutil_require_module('phabricator', 'applications/diffusion/data/branch'); phutil_require_module('phabricator', 'applications/diffusion/query/branch/base'); -phutil_require_module('phutil', 'future/exec'); - phutil_require_source('DiffusionGitBranchQuery.php'); diff --git a/src/applications/diffusion/query/browse/git/DiffusionGitBrowseQuery.php b/src/applications/diffusion/query/browse/git/DiffusionGitBrowseQuery.php index 02c25fee5c..973ae4a916 100644 --- a/src/applications/diffusion/query/browse/git/DiffusionGitBrowseQuery.php +++ b/src/applications/diffusion/query/browse/git/DiffusionGitBrowseQuery.php @@ -25,26 +25,22 @@ final class DiffusionGitBrowseQuery extends DiffusionBrowseQuery { $path = $drequest->getPath(); $commit = $drequest->getCommit(); - $local_path = $repository->getDetail('local-path'); - if ($path == '') { // Fast path to improve the performance of the repository view; we know // the root is always a tree at any commit and always exists. $stdout = 'tree'; } else { try { - list($stdout) = execx( - "(cd %s && git cat-file -t %s:%s)", - $local_path, + list($stdout) = $repository->execxLocalCommand( + 'cat-file -t %s:%s', $commit, $path); } catch (CommandException $e) { $stderr = $e->getStdErr(); if (preg_match('/^fatal: Not a valid object name/', $stderr)) { // Grab two logs, since the first one is when the object was deleted. - list($stdout) = execx( - '(cd %s && git log -n2 --format="%%H" %s -- %s)', - $local_path, + list($stdout) = $repository->execxLocalCommand( + 'log -n2 --format="%%H" %s -- %s', $commit, $path); $stdout = trim($stdout); @@ -73,9 +69,8 @@ final class DiffusionGitBrowseQuery extends DiffusionBrowseQuery { return true; } - list($stdout) = execx( - "(cd %s && git ls-tree -l %s:%s)", - $local_path, + list($stdout) = $repository->execxLocalCommand( + 'ls-tree -l %s:%s', $commit, $path); diff --git a/src/applications/diffusion/query/browse/git/__init__.php b/src/applications/diffusion/query/browse/git/__init__.php index 43e381b44f..ae74d932c4 100644 --- a/src/applications/diffusion/query/browse/git/__init__.php +++ b/src/applications/diffusion/query/browse/git/__init__.php @@ -10,7 +10,6 @@ phutil_require_module('phabricator', 'applications/differential/constants/change phutil_require_module('phabricator', 'applications/diffusion/data/repositorypath'); phutil_require_module('phabricator', 'applications/diffusion/query/browse/base'); -phutil_require_module('phutil', 'future/exec'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/diffusion/query/diff/git/DiffusionGitDiffQuery.php b/src/applications/diffusion/query/diff/git/DiffusionGitDiffQuery.php index 194a16e86a..e2ce756485 100644 --- a/src/applications/diffusion/query/diff/git/DiffusionGitDiffQuery.php +++ b/src/applications/diffusion/query/diff/git/DiffusionGitDiffQuery.php @@ -45,27 +45,24 @@ final class DiffusionGitDiffQuery extends DiffusionDiffQuery { $options = implode(' ', $options); try { - list($raw_diff) = execx( - "(cd %s && git diff %C %s^ %s -- %s)", - $repository->getDetail('local-path'), + list($raw_diff) = $repository->execxLocalCommand( + 'diff %C %s^ %s -- %s', $options, $effective_commit, $effective_commit, $drequest->getPath()); } catch (CommandException $ex) { // Check if this is the root commit by seeing if it has parents. - list($parents) = execx( - '(cd %s && git log --format=%s %s --)', - $repository->getDetail('local-path'), + list($parents) = $repository->execxLocalCommand( + 'log --format=%s %s --', '%P', // "parents" $effective_commit); if (!strlen(trim($parents))) { // No parents means we're looking at the root revision. Diff against // the empty tree hash instead, since there is no parent so "^" does // not work. See ArcanistGitAPI for more discussion. - list($raw_diff) = execx( - '(cd %s && git diff %C %s %s -- %s)', - $repository->getDetail('local-path'), + list($raw_diff) = $repository->execxLocalCommand( + 'diff %C %s %s -- %s', $options, ArcanistGitAPI::GIT_MAGIC_ROOT_COMMIT, $effective_commit, diff --git a/src/applications/diffusion/query/diff/git/__init__.php b/src/applications/diffusion/query/diff/git/__init__.php index d85a8e45c7..766d74997d 100644 --- a/src/applications/diffusion/query/diff/git/__init__.php +++ b/src/applications/diffusion/query/diff/git/__init__.php @@ -12,7 +12,5 @@ phutil_require_module('arcanist', 'repository/api/git'); phutil_require_module('phabricator', 'applications/differential/storage/diff'); phutil_require_module('phabricator', 'applications/diffusion/query/diff/base'); -phutil_require_module('phutil', 'future/exec'); - phutil_require_source('DiffusionGitDiffQuery.php'); diff --git a/src/applications/diffusion/query/filecontent/git/DiffusionGitFileContentQuery.php b/src/applications/diffusion/query/filecontent/git/DiffusionGitFileContentQuery.php index 4ca26355b9..0e427e4858 100644 --- a/src/applications/diffusion/query/filecontent/git/DiffusionGitFileContentQuery.php +++ b/src/applications/diffusion/query/filecontent/git/DiffusionGitFileContentQuery.php @@ -25,17 +25,14 @@ final class DiffusionGitFileContentQuery extends DiffusionFileContentQuery { $path = $drequest->getPath(); $commit = $drequest->getCommit(); - $local_path = $repository->getDetail('local-path'); if ($this->getNeedsBlame()) { - list($corpus) = execx( - '(cd %s && git --no-pager blame -c -l --date=short %s -- %s)', - $local_path, + list($corpus) = $repository->execxLocalCommand( + '--no-pager blame -c -l --date=short %s -- %s', $commit, $path); } else { - list($corpus) = execx( - '(cd %s && git cat-file blob %s:%s)', - $local_path, + list($corpus) = $repository->execxLocalCommand( + 'cat-file blob %s:%s', $commit, $path); } diff --git a/src/applications/diffusion/query/filecontent/git/__init__.php b/src/applications/diffusion/query/filecontent/git/__init__.php index 94c1835f75..9b01358c48 100644 --- a/src/applications/diffusion/query/filecontent/git/__init__.php +++ b/src/applications/diffusion/query/filecontent/git/__init__.php @@ -9,7 +9,6 @@ phutil_require_module('phabricator', 'applications/diffusion/data/filecontent'); phutil_require_module('phabricator', 'applications/diffusion/query/filecontent/base'); -phutil_require_module('phutil', 'future/exec'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/diffusion/query/history/git/DiffusionGitHistoryQuery.php b/src/applications/diffusion/query/history/git/DiffusionGitHistoryQuery.php index bf95cfe610..5d3fe73499 100644 --- a/src/applications/diffusion/query/history/git/DiffusionGitHistoryQuery.php +++ b/src/applications/diffusion/query/history/git/DiffusionGitHistoryQuery.php @@ -25,16 +25,13 @@ final class DiffusionGitHistoryQuery extends DiffusionHistoryQuery { $path = $drequest->getPath(); $commit_hash = $drequest->getCommit(); - $local_path = $repository->getDetail('local-path'); - - list($stdout) = execx( - '(cd %s && git log '. + list($stdout) = $repository->execxLocalCommand( + 'log '. '--skip=%d '. '-n %d '. '--abbrev=40 '. '--pretty=format:%%H '. - '%s -- %s)', - $local_path, + '%s -- %s', $this->getOffset(), $this->getLimit(), $commit_hash, diff --git a/src/applications/diffusion/query/history/git/__init__.php b/src/applications/diffusion/query/history/git/__init__.php index 1094fb4883..948d796aa8 100644 --- a/src/applications/diffusion/query/history/git/__init__.php +++ b/src/applications/diffusion/query/history/git/__init__.php @@ -8,7 +8,5 @@ phutil_require_module('phabricator', 'applications/diffusion/query/history/base'); -phutil_require_module('phutil', 'future/exec'); - phutil_require_source('DiffusionGitHistoryQuery.php'); diff --git a/src/applications/diffusion/query/lastmodified/git/DiffusionGitLastModifiedQuery.php b/src/applications/diffusion/query/lastmodified/git/DiffusionGitLastModifiedQuery.php index 3ac39f5a3e..be1113dbc9 100644 --- a/src/applications/diffusion/query/lastmodified/git/DiffusionGitLastModifiedQuery.php +++ b/src/applications/diffusion/query/lastmodified/git/DiffusionGitLastModifiedQuery.php @@ -22,9 +22,8 @@ final class DiffusionGitLastModifiedQuery extends DiffusionLastModifiedQuery { $drequest = $this->getRequest(); $repository = $drequest->getRepository(); - list($hash) = execx( - "(cd %s && git log -n1 --format=%%H %s -- %s)", - $repository->getDetail('local-path'), + list($hash) = $repository->execxLocalCommand( + 'log -n1 --format=%%H %s -- %s', $drequest->getCommit(), $drequest->getPath()); $hash = trim($hash); diff --git a/src/applications/diffusion/query/lastmodified/git/__init__.php b/src/applications/diffusion/query/lastmodified/git/__init__.php index 14b7716460..0f7241f74a 100644 --- a/src/applications/diffusion/query/lastmodified/git/__init__.php +++ b/src/applications/diffusion/query/lastmodified/git/__init__.php @@ -10,7 +10,6 @@ phutil_require_module('phabricator', 'applications/diffusion/query/lastmodified/ phutil_require_module('phabricator', 'applications/repository/storage/commit'); phutil_require_module('phabricator', 'applications/repository/storage/commitdata'); -phutil_require_module('phutil', 'future/exec'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/diffusion/request/git/DiffusionGitRequest.php b/src/applications/diffusion/request/git/DiffusionGitRequest.php index 4206daf0ca..82b244ea38 100644 --- a/src/applications/diffusion/request/git/DiffusionGitRequest.php +++ b/src/applications/diffusion/request/git/DiffusionGitRequest.php @@ -40,7 +40,7 @@ class DiffusionGitRequest extends DiffusionRequest { $this->path = implode('/', $parts); if ($this->repository) { - $local_path = $this->repository->getDetail('local-path'); + $repository = $this->repository; // TODO: This is not terribly efficient and does not produce terribly // good error messages, but it seems better to put error handling code @@ -52,15 +52,13 @@ class DiffusionGitRequest extends DiffusionRequest { // message to indicate whether they've typed in some bogus branch and/or // followed a bad link, or misconfigured the default branch in the // Repository tool. - list($this->stableCommitName) = execx( - '(cd %s && git rev-parse --verify %s)', - $local_path, + list($this->stableCommitName) = $repository->execxLocalCommand( + 'rev-parse --verify %s', $branch); if ($this->commit) { - list($commit) = execx( - '(cd %s && git rev-parse --verify %s)', - $local_path, + list($commit) = $repository->execxLocalCommand( + 'rev-parse --verify %s', $this->commit); // Beyond verifying them, expand commit short forms to full 40-character @@ -76,9 +74,8 @@ class DiffusionGitRequest extends DiffusionRequest { TODO: Unclear if this is actually a good idea or not; it breaks commit views at the very least. - list($contains) = execx( - '(cd %s && git branch --contains %s)', - $local_path, + list($contains) = $repository->execxLocalCommand( + 'branch --contains %s', $this->commit); $contains = array_filter(explode("\n", $contains)); $found = false; diff --git a/src/applications/diffusion/request/git/__init__.php b/src/applications/diffusion/request/git/__init__.php index 85a3411f63..f63f9da1b5 100644 --- a/src/applications/diffusion/request/git/__init__.php +++ b/src/applications/diffusion/request/git/__init__.php @@ -8,7 +8,5 @@ phutil_require_module('phabricator', 'applications/diffusion/request/base'); -phutil_require_module('phutil', 'future/exec'); - phutil_require_source('DiffusionGitRequest.php');