1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-01-22 20:51:09 +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:
Jim Meyering 2012-11-12 17:34:00 -08:00
parent 15e4e6a003
commit 515399c0f6

View file

@ -260,8 +260,14 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
return $this->relativeCommit;
}
private function getDiffFullOptions($detect_moves_and_renames = true) {
$options = array(
private function getDiffFullCommand($detect_moves_and_renames = true) {
$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(),
'--no-color',
'--src-prefix=a/',
@ -270,11 +276,11 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
);
if ($detect_moves_and_renames) {
$options[] = '-M';
$options[] = '-C';
$diff_cmd[] = '-M';
$diff_cmd[] = '-C';
}
return implode(' ', $options);
return implode(' ', $diff_cmd);
}
private function getDiffBaseOptions() {
@ -292,9 +298,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
}
public function getFullGitDiff() {
$options = $this->getDiffFullOptions();
$diff_cmd = $this->getDiffFullCommand();
list($stdout) = $this->execxLocal(
"diff {$options} %s --",
"{$diff_cmd} %s --",
$this->getRelativeCommit());
return $stdout;
}
@ -306,9 +312,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
* generate real diff text.
*/
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(
"diff {$options} %s -- %s",
"{$diff_cmd} %s -- %s",
$this->getRelativeCommit(),
$path);
return $stdout;