@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class DiffusionGitRawDiffQuery extends DiffusionRawDiffQuery {
4
5 protected function newQueryFuture() {
6 $drequest = $this->getRequest();
7 $repository = $drequest->getRepository();
8
9 $commit = $this->getAnchorCommit();
10
11 $options = array(
12 '-M',
13 '-C',
14 '--no-ext-diff',
15 '--no-color',
16 '--src-prefix=a/',
17 '--dst-prefix=b/',
18 '-U'.(int)$this->getLinesOfContext(),
19 );
20
21 $against = $this->getAgainstCommit();
22 if ($against === null) {
23 // Check if this is the root commit by seeing if it has parents, since
24 // `git diff X^ X` does not work if "X" is the initial commit.
25 list($parents) = $repository->execxLocalCommand(
26 'log -n 1 %s %s --',
27 '--format=%P',
28 gitsprintf('%s', $commit));
29
30 if (strlen(trim($parents))) {
31 $against = $commit.'^';
32 } else {
33 $against = ArcanistGitAPI::GIT_MAGIC_ROOT_COMMIT;
34 }
35 }
36
37 $path = $drequest->getPath();
38 if (!phutil_nonempty_string($path)) {
39 $path = '.';
40 }
41
42 return $repository->getLocalCommandFuture(
43 'diff %Ls %s %s -- %s',
44 $options,
45 gitsprintf('%s', $against),
46 gitsprintf('%s', $commit),
47 $path);
48 }
49
50}