From cddbe306f9274b1ea22af86763236ce88572338f Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 1 Apr 2019 10:38:25 -0700 Subject: [PATCH] Correct a case where a single-hunk diff may incorrectly be identified as multi-hunk by the Scope engine Summary: See PHI985. The layers above this may return `array()` to mean "one hunk with a line-1 offset". Accept either `array()` or `array(1 => ...)` to engage the scope engine. Test Plan: See PHI985. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D20363 --- .../differential/render/DifferentialChangesetRenderer.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/applications/differential/render/DifferentialChangesetRenderer.php b/src/applications/differential/render/DifferentialChangesetRenderer.php index 26de5cb53b..4ed77bf041 100644 --- a/src/applications/differential/render/DifferentialChangesetRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetRenderer.php @@ -684,7 +684,12 @@ abstract class DifferentialChangesetRenderer extends Phobject { // If this change is missing context, don't try to identify scopes, since // we won't really be able to get anywhere. $has_multiple_hunks = (count($hunk_starts) > 1); - $has_offset_hunks = (head_key($hunk_starts) != 1); + + $has_offset_hunks = false; + if ($hunk_starts) { + $has_offset_hunks = (head_key($hunk_starts) != 1); + } + $missing_context = ($has_multiple_hunks || $has_offset_hunks); if ($missing_context) {