]> khamidou — GitHub mirrors - arcanist.git/commit
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)
commitdfe2bde88d4f6d970012274ef761b6cb48c6b64e
tree4e8fbf9a4f3279e7acf12e75d7ce10190f6145a1
parent9492b4ecba12e672a50e0ba195507be7d8d1aa4a
Dirty cache of HEAD commit after an amend/range reload

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