You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The UnifiedDiff compares currently against a file from the workspace. As soon as a file is staged, the comparison falls back to the old compare editor as now two Git states (index vs head) are compared.
The fallback is decided in CompareUIPlugin.prepareUnifiedDiff(...) . The unified diff needs a workspace file ( IFileEditorInput ) to overlay onto:
if (leftEditorInput instanceof IFileEditorInput) { // working-tree side
return new UnifiedDiffSource(..., UnifiedDiffMode.REVERT_MODE, ...);
}
if (rightEditorInput instanceof IFileEditorInput) {
return new UnifiedDiffSource(..., UnifiedDiffMode.OVERLAY_READ_ONLY_MODE, ...);
}
return null; // ← neither side is a workspace file → classic compare editor
• Unstaged changes (working tree vs. index/HEAD): the left side is the workspace file → unified diff works. ✅
• Staged changes (index vs. HEAD): both sides are Git revisions, neither is an IFileEditorInput → prepareUnifiedDiff returns null → classic compare. ❌
Not sure how we should handle that. Should we still compare against the workspace file? Or leave that to the old compare?
Good point, I am aware of this limitation. Can we open a text editor for a Git revision? What is the editor input then? I will take a deeper look when I get time.
Can we open a text editor for a Git revision? What is the editor input then?
Not sure who is meant by "we", but egit can that. If I remember right, it extract the revision to a temp fle outside the workspace. Same with any other revision from the history which is not on disk.
Good point, I am aware of this limitation. Can we open a text editor for a Git revision? What is the editor input then? I will take a deeper look when I get time.
Current logic, which should also work for Git files:
File is compared that is changed in working tree -> Equivalent to git diff
File compared that is staged-> Equivalent to git --cached
Activity
tobiasmelcher commentedon Aug 11, 2026
Good point, I am aware of this limitation. Can we open a text editor for a Git revision? What is the editor input then? I will take a deeper look when I get time.
iloveeclipse commentedon Aug 11, 2026
Not sure who is meant by "we", but egit can that. If I remember right, it extract the revision to a temp fle outside the workspace. Same with any other revision from the history which is not on disk.
vogella commentedon Aug 11, 2026
Current logic, which should also work for Git files:
File is compared that is changed in working tree -> Equivalent to git diff
File compared that is staged-> Equivalent to git --cached