From 6929f4e57e7a641d00caf8bf511bbd97d7e8a051 Mon Sep 17 00:00:00 2001 From: vrana Date: Wed, 19 Sep 2012 14:36:38 -0700 Subject: [PATCH] Build correct corpus in copied or moved files Summary: This problem shows very far away. One of the symptomps is that the contents of a moved file is displayed as added in Differential but it is not a big deal. The real trouble happens when you try to `arc patch` this diff. It tries to both copy the file and to add a new contents (which fails). Fixes T1709. Test Plan: $ git mv a b $ git commit -m. $ arc diff --only $ git reset --hard HEAD^ $ arc patch --diff # of the created diff $ arc unit src/parser/__tests__ Reviewers: epriestley, btrahan Reviewed By: btrahan CC: aran, Korvin, boris, mroch, slawekbiel Maniphest Tasks: T1709 Differential Revision: https://secure.phabricator.com/D3524 --- src/workflow/ArcanistDiffWorkflow.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index f2aab999..f645cc82 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -997,6 +997,10 @@ EOTEXT if ($raw_change->getCurrentPath() == $path) { $change->setFileType($raw_change->getFileType()); foreach ($raw_change->getHunks() as $hunk) { + // Git thinks that this file has been added. But we know that it + // has been moved or copied without a change. + $hunk->setCorpus( + preg_replace('/^\+/m', ' ', $hunk->getCorpus())); $change->addHunk($hunk); } break;