]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Dirty cache of HEAD commit after an amend/range reload
authorepriestley <git@epriestley.com>
Thu, 12 Jun 2014 22:46:15 +0000 (15:46 -0700)
committerepriestley <git@epriestley.com>
Thu, 12 Jun 2014 22:46:15 +0000 (15:46 -0700)
Summary:
Introducing `--head` caused us to run `git diff base..head` explicitly.

However, we can now hit this workflow:

  - We resolve `HEAD` as commit `aaaa1`.
  - This is cached.
  - We notice dirty working copy changes and prompt the user to amend them to HEAD.
  - The user accepts the amend.
  - We amend, creating commit `bbbb2`.
  - We dirty the commit range and reload the working copy. This //does not// dirty the cache of HEAD.
  - We run `git diff`, but it uses the old cached HEAD: `git diff base..aaaa1`.
  - This works fine (`aaaa1` still exists, it's just not on any branch) but produces the wrong diff (without amended changes).

To resolve this, implement the "dirty the cache when the range reloads" hook.

Also never try to amend if the user provides `--head`.

Test Plan:
Ran `arc diff --only --trace` in a working copy with a new commit and some uncommitted changes.

  - Prior to this change, saw a `git diff base..aaaa1` command and the wrong diff.
  - After this change, saw a `git diff base..bbbb2` command and the correct diff.

Reviewers: chad, csilvers, talshiri

Reviewed By: talshiri

Subscribers: epriestley, spicyj

Differential Revision: https://secure.phabricator.com/D9506

src/repository/api/ArcanistGitAPI.php
src/workflow/ArcanistDiffWorkflow.php

index df4412100517c5a7d3b3d8f0f191c2e9b3fab511..ed8008d83ae87907213d336081b3d8a8977decf5 100644 (file)
@@ -1202,4 +1202,9 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
     $this->execxLocal('stash pop');
   }
 
+  protected function didReloadCommitRange() {
+    // After an amend, the symbolic head may resolve to a different commit.
+    $this->resolvedHeadCommit = null;
+  }
+
 }
index 699ffad14535795ec036f2645963c3f6217d044c..a539bab29fa80b3a13fd2eee8d344c9757b4df29 100644 (file)
@@ -1207,6 +1207,10 @@ EOTEXT
       return false;
     }
 
+    if ($this->getArgument('head') !== null) {
+      return false;
+    }
+
     // Run this last: with --raw or --raw-command, we won't have a repository
     // API.
     if ($this->isHistoryImmutable()) {