]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix "arc lint" when HEAD has been reverted in the working copy
authorepriestley <git@epriestley.com>
Wed, 29 Feb 2012 20:18:46 +0000 (12:18 -0800)
committerepriestley <git@epriestley.com>
Wed, 29 Feb 2012 20:18:46 +0000 (12:18 -0800)
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
src/repository/api/mercurial/ArcanistMercurialAPI.php

index 890f17ab5d6a6f39b916aa774e9e8f977f75b787..89fc1fb8c1c8ea2914c7957b175c5cad0fc830aa 100644 (file)
@@ -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);
   }
index 4c4cb31652a51e2134cdd1998e5a15a4bec25bf8..7bbeb4653826fff48e3511d6cc4e6248e935d044 100644 (file)
@@ -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);
   }