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.