From eb49d8a52b16cf59b826d9b71ac5336dd0d8ba51 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 1 Jul 2013 09:02:55 -0700 Subject: [PATCH] Construct diffs with attached changesets, even if empty Summary: See discussion in IRC. Not 100% sure what's going on here because of email ghost theives, but conceivably a commit with no changes will end up with `null` changesets instead of `array()` changesets, which throws. Such diffs are certianly possible (`git commit --allow-empty`) even if they aren't the issue in this specific case. See T3416. Initialize changesets to `array()` to avoid throwing. Test Plan: Viewed some commits? iiam Reviewers: btrahan, chad Reviewed By: chad CC: aran Differential Revision: https://secure.phabricator.com/D6339 --- src/applications/differential/storage/DifferentialDiff.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/applications/differential/storage/DifferentialDiff.php b/src/applications/differential/storage/DifferentialDiff.php index f0eac81935..b53455ade3 100644 --- a/src/applications/differential/storage/DifferentialDiff.php +++ b/src/applications/differential/storage/DifferentialDiff.php @@ -115,6 +115,10 @@ final class DifferentialDiff extends DifferentialDAO { assert_instances_of($changes, 'ArcanistDiffChange'); $diff = new DifferentialDiff(); + // There may not be any changes; initialize the changesets list so that + // we don't throw later when accessing it. + $diff->attachChangesets(array()); + $lines = 0; foreach ($changes as $change) { if ($change->getType() == ArcanistDiffChangeType::TYPE_MESSAGE) { -- 2.51.2