1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-27 16:00:58 +01:00

When generating diffs in "arc diff", disable Git config option "diff.suppressBlankEmpty"

Summary:
Ref T13432. Git has a "diff.suppressBlankEmpty" config option which makes it emit nonstandard diffs with trimmed trailing whitespace on unchanged blank lines.

Currently, we don't parse these diffs correctly. Even if we do in the future, emitting a more standard diff is desirable.

Explicitly disable this option when executing "git diff" so we build more standard diffs.

Test Plan:
  - Configured this option.
  - Modified a file with a blank line in it without changing the blank line, got this goofy display diff:

{F6985234}

  - Applied patch, rediffed the same change, saw "-c diff.suppressBlankEmpty" in "--trace" output and got this sensible diff:

{F6985235}

Maniphest Tasks: T13432

Differential Revision: https://secure.phabricator.com/D20877
This commit is contained in:
epriestley 2019-10-29 10:09:45 -07:00
parent 73943d1bc9
commit cc1ff38843

View file

@ -464,15 +464,27 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
*/
public function getFullGitDiff($base, $head = null) {
$options = $this->getDiffFullOptions();
$config_options = array();
// See T13432. Disable the rare "diff.suppressBlankEmpty" configuration
// option, which discards the " " (space) change type prefix on unchanged
// blank lines. At time of writing the parser does not handle these
// properly, but generating a more-standard diff is generally desirable
// even if a future parser handles this case more gracefully.
$config_options[] = '-c';
$config_options[] = 'diff.suppressBlankEmpty=false';
if ($head !== null) {
list($stdout) = $this->execxLocal(
"diff {$options} %s %s --",
"%LR diff {$options} %s %s --",
$config_options,
$base,
$head);
} else {
list($stdout) = $this->execxLocal(
"diff {$options} %s --",
"%LR diff {$options} %s --",
$config_options,
$base);
}