From 6430d6d638eb49e139adfa4601134cc96958cee6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 4 May 2020 15:34:27 -0700 Subject: [PATCH] Fix an intradiff error when the newer changeset does not exist Summary: Ref T13523. If a file hasn't been touched in the newer changeset, we can currently hit an error in the interdiff. Test Plan: - Touched "moo.txt" in Diff 1. - Reverted the changes to "moo.txt" in Diff 2. - Diffed 2 vs 1. - Before patch: fatal (call to getFilename() on null). - After patch: clean interdiff. Maniphest Tasks: T13523 Differential Revision: https://secure.phabricator.com/D21220 --- .../differential/storage/DifferentialChangeset.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/applications/differential/storage/DifferentialChangeset.php b/src/applications/differential/storage/DifferentialChangeset.php index fa4cc37ec8..d7d66ae97d 100644 --- a/src/applications/differential/storage/DifferentialChangeset.php +++ b/src/applications/differential/storage/DifferentialChangeset.php @@ -560,12 +560,16 @@ final class DifferentialChangeset $right_state = $right->hasNewState(); $shared_metadata = $right->getMetadata(); $right_type = $right->getNewFileType(); + + $file_name = $right->getFilename(); } else { $right_data = $left->makeOldFile(); $right_properties = $left->getOldProperties(); $right_metadata = $left->getOldStateMetadata(); $right_state = $left->hasOldState(); $right_type = $left->getOldFileType(); + + $file_name = $left->getFilename(); } $engine = new PhabricatorDifferenceEngine(); @@ -578,7 +582,7 @@ final class DifferentialChangeset ->makeEphemeral(true) ->attachDiff($left->getDiff()) ->setOldFile($left->getFilename()) - ->setFilename($right->getFilename()); + ->setFilename($file_name); // TODO: Change type? // TODO: Away paths?