mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-02 09:58:23 +01:00
accommodate git's diff.suppress-blank-empty=true setting
Summary: accommodate git's diff.suppress-blank-empty=true setting Without this change, if you were to set diff.suppress-blank-empty=true in your .gitconfig (as I do), then "arc diff" would always fail with the cryptic diagnostic, "Diff Parse Exception: Found the wrong number of hunk lines." Test Plan: Put this in ~/.gitconfig or .git/config [diff] suppress-blank-empty = true and run "arc lint". It should pass. Without this chnage, it would fail as described above. Reviewers: vrana, epriestley Reviewed By: vrana CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3963
This commit is contained in:
parent
15e4e6a003
commit
515399c0f6
1 changed files with 15 additions and 9 deletions
|
@ -260,8 +260,14 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
return $this->relativeCommit;
|
return $this->relativeCommit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDiffFullOptions($detect_moves_and_renames = true) {
|
private function getDiffFullCommand($detect_moves_and_renames = true) {
|
||||||
$options = array(
|
$diff_cmd = array(
|
||||||
|
// Our diff parser relies on the trailing spaces that are suppressed
|
||||||
|
// when the diff.suppress-blank-empty boolean is set to "true".
|
||||||
|
// Without the following, "arc lint" would always fail with this:
|
||||||
|
// "Diff Parse Exception: Found the wrong number of hunk lines."
|
||||||
|
'-c diff.suppress-blank-empty=false',
|
||||||
|
'diff',
|
||||||
self::getDiffBaseOptions(),
|
self::getDiffBaseOptions(),
|
||||||
'--no-color',
|
'--no-color',
|
||||||
'--src-prefix=a/',
|
'--src-prefix=a/',
|
||||||
|
@ -270,11 +276,11 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($detect_moves_and_renames) {
|
if ($detect_moves_and_renames) {
|
||||||
$options[] = '-M';
|
$diff_cmd[] = '-M';
|
||||||
$options[] = '-C';
|
$diff_cmd[] = '-C';
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode(' ', $options);
|
return implode(' ', $diff_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDiffBaseOptions() {
|
private function getDiffBaseOptions() {
|
||||||
|
@ -292,9 +298,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFullGitDiff() {
|
public function getFullGitDiff() {
|
||||||
$options = $this->getDiffFullOptions();
|
$diff_cmd = $this->getDiffFullCommand();
|
||||||
list($stdout) = $this->execxLocal(
|
list($stdout) = $this->execxLocal(
|
||||||
"diff {$options} %s --",
|
"{$diff_cmd} %s --",
|
||||||
$this->getRelativeCommit());
|
$this->getRelativeCommit());
|
||||||
return $stdout;
|
return $stdout;
|
||||||
}
|
}
|
||||||
|
@ -306,9 +312,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
* generate real diff text.
|
* generate real diff text.
|
||||||
*/
|
*/
|
||||||
public function getRawDiffText($path, $detect_moves_and_renames = true) {
|
public function getRawDiffText($path, $detect_moves_and_renames = true) {
|
||||||
$options = $this->getDiffFullOptions($detect_moves_and_renames);
|
$diff_cmd = $this->getDiffFullCommand($detect_moves_and_renames);
|
||||||
list($stdout) = $this->execxLocal(
|
list($stdout) = $this->execxLocal(
|
||||||
"diff {$options} %s -- %s",
|
"{$diff_cmd} %s -- %s",
|
||||||
$this->getRelativeCommit(),
|
$this->getRelativeCommit(),
|
||||||
$path);
|
$path);
|
||||||
return $stdout;
|
return $stdout;
|
||||||
|
|
Loading…
Add table
Reference in a new issue