Path: blob/master/src/applications/diffusion/query/rawdiff/DiffusionGitRawDiffQuery.php
12242 views
<?php12final class DiffusionGitRawDiffQuery extends DiffusionRawDiffQuery {34protected function newQueryFuture() {5$drequest = $this->getRequest();6$repository = $drequest->getRepository();78$commit = $this->getAnchorCommit();910$options = array(11'-M',12'-C',13'--no-ext-diff',14'--no-color',15'--src-prefix=a/',16'--dst-prefix=b/',17'-U'.(int)$this->getLinesOfContext(),18);1920$against = $this->getAgainstCommit();21if ($against === null) {22// Check if this is the root commit by seeing if it has parents, since23// `git diff X^ X` does not work if "X" is the initial commit.24list($parents) = $repository->execxLocalCommand(25'log -n 1 %s %s --',26'--format=%P',27gitsprintf('%s', $commit));2829if (strlen(trim($parents))) {30$against = $commit.'^';31} else {32$against = ArcanistGitAPI::GIT_MAGIC_ROOT_COMMIT;33}34}3536$path = $drequest->getPath();37if ($path === null || !strlen($path)) {38$path = '.';39}4041return $repository->getLocalCommandFuture(42'diff %Ls %s %s -- %s',43$options,44gitsprintf('%s', $against),45gitsprintf('%s', $commit),46$path);47}4849}505152