Changeset View
Changeset View
Standalone View
Standalone View
src/repository/api/ArcanistGitAPI.php
| <?php | <?php | ||||
| /** | /** | ||||
| * Interfaces with Git working copies. | * Interfaces with Git working copies. | ||||
| * | |||||
| * @group workingcopy | |||||
| */ | */ | ||||
| final class ArcanistGitAPI extends ArcanistRepositoryAPI { | final class ArcanistGitAPI extends ArcanistRepositoryAPI { | ||||
| private $repositoryHasNoCommits = false; | private $repositoryHasNoCommits = false; | ||||
| const SEARCH_LENGTH_FOR_PARENT_REVISIONS = 16; | const SEARCH_LENGTH_FOR_PARENT_REVISIONS = 16; | ||||
| /** | /** | ||||
| * For the repository's initial commit, 'git diff HEAD^' and similar do | * For the repository's initial commit, 'git diff HEAD^' and similar do | ||||
| * not work. Using this instead does work; it is the hash of the empty tree. | * not work. Using this instead does work; it is the hash of the empty tree. | ||||
| */ | */ | ||||
| const GIT_MAGIC_ROOT_COMMIT = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'; | const GIT_MAGIC_ROOT_COMMIT = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'; | ||||
| private $symbolicHeadCommit; | private $symbolicHeadCommit; | ||||
| private $resolvedHeadCommit; | private $resolvedHeadCommit; | ||||
| public static function newHookAPI($root) { | public static function newHookAPI($root) { | ||||
| return new ArcanistGitAPI($root); | return new ArcanistGitAPI($root); | ||||
| } | } | ||||
| protected function buildLocalFuture(array $argv) { | protected function buildLocalFuture(array $argv) { | ||||
| $argv[0] = 'git '.$argv[0]; | $argv[0] = 'git '.$argv[0]; | ||||
| $future = newv('ExecFuture', $argv); | $future = newv('ExecFuture', $argv); | ||||
| $future->setCWD($this->getPath()); | $future->setCWD($this->getPath()); | ||||
| return $future; | return $future; | ||||
| } | } | ||||
| public function execPassthru($pattern /* , ... */) { | public function execPassthru($pattern /* , ... */) { | ||||
| ▲ Show 20 Lines • Show All 506 Lines • ▼ Show 20 Lines | final class ArcanistGitAPI extends ArcanistRepositoryAPI { | ||||
| } | } | ||||
| private function executeSVNFindRev($input, $vcs) { | private function executeSVNFindRev($input, $vcs) { | ||||
| $match = array(); | $match = array(); | ||||
| list($stdout) = $this->execxLocal( | list($stdout) = $this->execxLocal( | ||||
| 'svn find-rev %s', | 'svn find-rev %s', | ||||
| $input); | $input); | ||||
| if (!$stdout) { | if (!$stdout) { | ||||
| throw new ArcanistUsageException("Cannot find the {$vcs} equivalent " | throw new ArcanistUsageException( | ||||
| ."of {$input}."); | "Cannot find the {$vcs} equivalent of {$input}."); | ||||
| } | } | ||||
| // When git performs a partial-rebuild during svn | // When git performs a partial-rebuild during svn | ||||
| // look-up, we need to parse the final line | // look-up, we need to parse the final line | ||||
| $lines = explode("\n", $stdout); | $lines = explode("\n", $stdout); | ||||
| $stdout = $lines[count($lines) - 2]; | $stdout = $lines[count($lines) - 2]; | ||||
| return rtrim($stdout); | return rtrim($stdout); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 269 Lines • ▼ Show 20 Lines | foreach ($lines as $line) { | ||||
| 'type' => $matches[2], | 'type' => $matches[2], | ||||
| 'ref' => $matches[3], | 'ref' => $matches[3], | ||||
| ); | ); | ||||
| } | } | ||||
| return $result; | return $result; | ||||
| } | } | ||||
| private function getFileDataAtRevision($path, $revision) { | private function getFileDataAtRevision($path, $revision) { | ||||
| // NOTE: We don't want to just "git show {$revision}:{$path}" since if the | // NOTE: We don't want to just "git show {$revision}:{$path}" since if the | ||||
| // path was a directory at the given revision we'll get a list of its files | // path was a directory at the given revision we'll get a list of its files | ||||
| // and treat it as though it as a file containing a list of other files, | // and treat it as though it as a file containing a list of other files, | ||||
| // which is silly. | // which is silly. | ||||
| list($stdout) = $this->execxLocal( | list($stdout) = $this->execxLocal( | ||||
| 'ls-tree %s -- %s', | 'ls-tree %s -- %s', | ||||
| $revision, | $revision, | ||||
| ▲ Show 20 Lines • Show All 371 Lines • Show Last 20 Lines | |||||