From f9a7cb225ef49814cfd90d71e89e2de0300a0cf5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 29 Feb 2012 12:18:46 -0800 Subject: [PATCH] Fix "arc lint" when HEAD has been reverted in the working copy Summary: If a user reverts HEAD in the index or working copy, "git diff" shows no changes and we explode. Instead, we should simply return no changes; the rest of the lint pipeline accommodates this correctly. Test Plan: Reverted HEAD in a working copy, ran "arc lint", got an error. Applied patch, ran "arc lint", got accurate lint. Reviewers: Koolvin, btrahan Reviewed By: Koolvin CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1729 --- src/repository/api/git/ArcanistGitAPI.php | 3 +++ src/repository/api/mercurial/ArcanistMercurialAPI.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/repository/api/git/ArcanistGitAPI.php b/src/repository/api/git/ArcanistGitAPI.php index 890f17ab..89fc1fb8 100644 --- a/src/repository/api/git/ArcanistGitAPI.php +++ b/src/repository/api/git/ArcanistGitAPI.php @@ -581,6 +581,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { public function getAllLocalChanges() { $diff = $this->getFullGitDiff(); + if (!strlen(trim($diff))) { + return array(); + } $parser = new ArcanistDiffParser(); return $parser->parseDiff($diff); } diff --git a/src/repository/api/mercurial/ArcanistMercurialAPI.php b/src/repository/api/mercurial/ArcanistMercurialAPI.php index 4c4cb316..7bbeb465 100644 --- a/src/repository/api/mercurial/ArcanistMercurialAPI.php +++ b/src/repository/api/mercurial/ArcanistMercurialAPI.php @@ -362,6 +362,9 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { public function getAllLocalChanges() { $diff = $this->getFullMercurialDiff(); + if (!strlen(trim($diff))) { + return array(); + } $parser = new ArcanistDiffParser(); return $parser->parseDiff($diff); } -- 2.43.0