]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Correctly detect uncommitted files in Git
authorepriestley <epriestley@phabricator.com>
Wed, 6 Apr 2011 02:27:05 +0000 (19:27 -0700)
committerepriestley <epriestley@phabricator.com>
Wed, 6 Apr 2011 04:08:55 +0000 (21:08 -0700)
Summary:
I simplified this code at some point and broke it horribly
in the process. Mask in the right flag here and combine the maps
correctly. This solves the great mystery of increased developer
clowniness.

Test Plan:
Ran 'arc diff' in a working copy with staged but
uncommitted files, got an error message (previously, I didn't).

Reviewed By: aran
Reviewers: mroch, aran
CC: aran
Differential Revision: 104

src/repository/api/git/ArcanistGitAPI.php

index cc961d35f0d9d2c6cbf4588dbbb4d83136149fe3..7ac4af56abdd7052208bc7d57b630c5de3b6e641 100644 (file)
@@ -168,7 +168,14 @@ class ArcanistGitAPI extends ArcanistRepositoryAPI {
       list($stdout) = execx(
         '(cd %s; git diff --no-ext-diff --raw HEAD --)',
         $this->getPath());
-      $files += $this->parseGitStatus($stdout);
+      $uncommitted_files = $this->parseGitStatus($stdout);
+      foreach ($uncommitted_files as $path => $mask) {
+        $mask |= self::FLAG_UNCOMMITTED;
+        if (!isset($files[$path])) {
+          $files[$path] = 0;
+        }
+        $files[$path] |= $mask;
+      }
 
       // Find untracked files.
       list($stdout) = execx(