1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-26 00:32:41 +01:00

Fix arc diff when run from a git submodule

Summary:
A git submodule looks a lot like a normal git repo, but the .git
directory is replaced with a file that git reads to find the real
location of the git directory. When arcanist tries to write a file into
a directory inside of there, it was failing silently, and then crashing
silently when it couldn't read results back out. Instead of assuming the
git directory is a directory named .git at the toplevel of the tree, we
use the appropriate git command to get the correct git directory.

Test Plan: submit a diff from a submodule

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4482
This commit is contained in:
Nick Harper 2013-01-17 11:28:13 -08:00
parent a39b591c95
commit 40102252bf
2 changed files with 16 additions and 2 deletions

View file

@ -35,7 +35,19 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
}
public function getMetadataPath() {
return $this->getPath('.git');
static $path = null;
if ($path === null) {
list($stdout) = $this->execxLocal('rev-parse --git-dir');
$path = rtrim($stdout, "\n");
// the output of git rev-parse --git-dir is an absolute path, unless
// the cwd is the root of the repository, in which case it uses the
// relative path of .git. If we get this relative path, turn it into
// an absolute path.
if ($path === '.git') {
$path = $this->getPath('.git');
}
}
return $path;
}
public function getHasCommits() {

View file

@ -445,7 +445,9 @@ EOTEXT
list($err) = $lint_unit->resolve();
$data = $this->readScratchJSONFile('diff-result.json');
if ($err || !$data) {
return 1;
throw new Exception(
'Unable to read results from background linting and unit testing. '.
'You can try running arc diff again with --background 0');
}
} else {
$server = $this->console->getServer();