eclipse-platform / eclipse-platform/eclipse.platform
UnifiedDiff for staged files with Git
- Vorherrschende Sprache
- Java
- Sterne
- 165
- Forks
- 174
- Ø Merge
- 2 T. 8 Std.
- Gemergte PRs (30 T.)
- 22
Beschreibung
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?
cc @tobiasmelcher
Beitragsleitfaden
Rechercherichtung
Beginnen Sie in CompareUIPlugin.prepareUnifiedDiff(...) und verfolgen Sie, wie IFileEditorInput, UnifiedDiffSource und der Fallback-Compare-Editor ausgewählt werden. Vergleichen Sie den staged index-versus-HEAD-Pfad mit dem unstaged workspace-file-Pfad und ermitteln und dokumentieren Sie anschließend das erwartete Unified-Diff-Verhalten für staged Dateien. Als abgeschlossen gilt die Aufgabe, wenn das gewählte Verhalten implementiert und durch die relevanten Vergleichsprüfungen abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100