From: epriestley Date: Wed, 29 Feb 2012 20:18:46 +0000 (-0800) Subject: Fix "arc lint" when HEAD has been reverted in the working copy X-Git-Tag: conduit-4~133 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=f9a7cb225ef49814cfd90d71e89e2de0300a0cf5;p=arcanist.git 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 --- 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); }