diff --git a/conf/default.conf.php b/conf/default.conf.php index 8b837d9be6..00e0c36cda 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -416,6 +416,12 @@ return array( // DifferentialCommitMessageModifier 'differential.modify-commit-message-class' => null, + // List of file regexps were whitespace is meaningful and should not + // use 'ignore-all' by default + 'differential.whitespace-matters' => array( + '/\.py$/', + ), + // -- Maniphest ------------------------------------------------------------- // diff --git a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php index 8e4b24b4ac..9d1b39d4a2 100644 --- a/src/applications/differential/parser/changeset/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/changeset/DifferentialChangesetParser.php @@ -767,6 +767,10 @@ class DifferentialChangesetParser { $ignore_all = ($this->whitespaceMode == self::WHITESPACE_IGNORE_ALL); + if ($ignore_all && $changeset->getWhitespaceMatters()) { + $ignore_all = false; + } + // The "ignore all whitespace" algorithm depends on rediffing the // files, and we currently need complete representations of both // files to do anything reasonable. If we only have parts of the files, diff --git a/src/applications/differential/storage/changeset/DifferentialChangeset.php b/src/applications/differential/storage/changeset/DifferentialChangeset.php index 758e311c8f..b8f398ab15 100644 --- a/src/applications/differential/storage/changeset/DifferentialChangeset.php +++ b/src/applications/differential/storage/changeset/DifferentialChangeset.php @@ -184,4 +184,15 @@ class DifferentialChangeset extends DifferentialDAO { return 80; } + public function getWhitespaceMatters() { + $config = PhabricatorEnv::getEnvConfig('differential.whitespace-matters'); + foreach ($config as $regexp) { + if (preg_match($regexp, $this->getFileName())) { + return true; + } + } + + return false; + } + } diff --git a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php index df14dfa595..c2711f588a 100644 --- a/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php +++ b/src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php @@ -173,7 +173,7 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView { )); $options = array( - 'ignore-all' => 'Ignore All', + 'ignore-all' => 'Ignore Most', 'ignore-trailing' => 'Ignore Trailing', 'show-all' => 'Show All', );