Fix the enablement of "Compare with->Index with HEAD"
This menu command makes sense only for staged files, but it was enabled
wrongly also on unstaged files. Apparently that was done on purpose in
commit
6d975be6 to avoid a costly index diff calculation to find out
whether the file was staged.
But if we are able to display "staged" decorations speedily, we
certainly are also able to determine quickly whether a file is staged.
Make isEnabled() properly check again, using the same mechanisms we use
for decorations, which rely on the IndexDiffCache. Remove the extra
check when the command is run, including the dialog.
There is one quirk here: these "Compare With..." actions are contributed
using the old (and deprecated) org.eclipse.ui.popupMenus extension point
with <objectContribution>. They get invoked via RepositoryAction, which
has some extra logic to avoid re-computing enablement when the selection
didn't change as far as resources are concerned. This of course goes
wrong if the enablement state of a handler depends on other state that
may have changed, such as the resources git state (staged/modified/...).
Add some logic to enforce always updating enablement for such handlers.
This works and is even uncritical when typing in an editor because:
* determining staging state via the IndexDiffCache is fast, and
* the enablement is only computed when the context menu is opened.
Change-Id: Ic6ec1e407f2ba1403ae52bc09b4f2546f4e221c8
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>