Repository navigation
One Diff View
Nibtree shows a file's diff in many places: the Changes diff and the Changes tab, a commit in the History panel or its own tab, a branch compare, Compare with Revision, the diff of a revision against the working tree, a shelf, Compare Files and local history. They all go through one component, GitDiffView, so they share the same toolbar, layouts, three-pane option and buttons.
Each place used to pick between the two-pane DiffView and the three-pane ThreePaneDiff on its own. So they drifted apart: the Changes tab had a Revert button the History panel did not, only merge commits could show three columns, and every fix had to be made several times. A user saw "the same view" behave differently depending on where it opened.
A place loads its two-pane diff as before and hands GitDiffView a DiffSource: what the diff compares.
| Source | Used by | Three panes | Change buttons |
|---|---|---|---|
changes |
Changes diff | HEAD, index, work tree | Stage, Unstage, Discard (the place's own) |
head |
Changes tab | HEAD, index, work tree | Revert to HEAD |
commit |
History panel, commit tab | parent, commit, work tree (or both parents of a merge) | Revert, Apply |
revisions |
Branch compare, Compare with Revision, revision against work tree | older, newer, work tree (only when the newer side is not the work tree) | Revert, plus Apply when the newer side is a revision |
plain |
Shelf, Compare Files, local history | none | none |
flowchart LR
Place["a place loads its diff"] --> View["GitDiffView(source, diff)"]
View --> Kind["threePaneKind(source, diff)"]
Kind -->|"three columns on and fits"| Three["ThreePaneDiff"]
Kind -->|"otherwise"| Two["DiffView"]
View --> Revs["changeRevisions(source)"]
Revs --> Actions["changeWorkTree: apply_revision_lines"]
diffSource.ts holds the pure decisions: threePaneKind (which three panes fit), panesKey (the Settings > Git choice that picks two or three columns: one for uncommitted changes, one for commits) and changeRevisions (the two revisions a change's Revert and Apply work between).
When three columns are on, GitDiffView loads the third pane itself: StagingDiffs for the index and the work tree, or WorkTreePane for the work tree against the newer side. Both reload when the repository's status or a file version changes, and panes still loaded for another file are never shown.
changeWorkTree (diffActions.ts) calls the apply_revision_lines command with the change's lines. The backend (commands/revision_lines.rs) reads both sides at their revisions (or the work tree file), builds a patch of only those lines with git::partial, and runs git apply (Apply) or git apply --reverse (Revert) on the work tree file after a --check. The index is never touched. A local history snapshot is taken first, and the patch comes back so the toast's Undo can run it the other way through restore_discarded_lines.
In three panes, the commit's bands sit between the parent and the middle, so ThreePaneDiff takes lineActions for that side: ThreeWayEditors.change(side, index) turns a band into the same line selection (side pane old, middle new).
| File | What it does |
|---|---|
src/lib/diff/GitDiffView.svelte |
The one view: picks the panes, loads the third one, wires the buttons |
src/lib/diff/diffSource.ts |
DiffSource, threePaneKind, panesKey, changeRevisions
|
src/lib/diff/diffActions.ts |
writeIndex (staging view) and changeWorkTree (Revert, Apply, Undo) |
src/lib/diff/workTreePane.svelte.ts |
The work tree pane next to a commit or a compare |
src-tauri/src/commands/revision_lines.rs |
apply_revision_lines |
- Places keep loading their own two-pane diff. Each one already loads, refreshes and lists files its own way; the view only needs the result and what it compares.
- Apply needs a revision on the newer side. When the newer side is the work tree, the change is already there, so only Revert is offered.
- The patch, not the texts. Applying a patch with context fails cleanly when the file moved on, instead of overwriting lines the user changed.
- Shelf, Compare Files and local history stay read-only. They are not git revisions of the same file, so a change has no clear place to go.
-
src/lib/diff/diffSource.test.ts: which panes fit each source, the settings, the revisions, a band's lines and the work tree pane against the middle. -
commands/revision_lines.rs: revert and apply one change with Undo, a change that no longer fits, a root commit's new file, the index left alone, and bad input.
Update the table when a place starts showing diffs, when a source kind changes, or when a button is added. See also How diffs work and How reverting a change works.
These pages are generated from docs/wiki. To correct something, open a pull request against the source file; edits made here are overwritten.
Using Nibtree
- Getting Started
- Welcome Screen
- Workspaces
- Files Panel
- File Operations
- File Icons
- Rounded Panels
- Editor and Tabs
- Pin Reorder and Wrap Tabs
- Single Tab Title
- Split Editor
- New File and Unsaved Changes
- Unload Hidden Tabs
- Editing Code
- Code Appearance
- Markdown Editor
- Image and PDF Preview
- Search Everywhere
- Recent Files
- Navigation Bar
- Find and Replace
- Changes and Commits
- Sign In Prompts
- Commit Box Layout
- Repository Actions
- Commit Options
- Ignoring Files
- Diffs
- Inline Diffs
- Staging View
- Revert a Change
- Resolving Conflicts
- Merge Tool
- Blame
- History and Log
- Merge Commits
- Branches and Tags
- Branches Popup
- Remotes
- Stashes
- Shelf
- Git Menu
- Git Dialogs
- Interactive Rebase
- Worktrees
- AI Agents
- AI Tasks
- AI Usage
- Keep Computer Awake
- Submodules
- Git LFS
- GitHub
- Git Console
- Terminal
- Terminal Features
- Scripts
- Navigation
- Menus
- Settings
- Settings Search
- Color Themes
- Settings Terminal and Automation
- Settings Files
- Updates
- Status Bar and Help
- Notifications
- Memory Use
- Clear Cache
- MCP and CLI
- Git Mergetool
- Keyboard Shortcuts
- Keyboard Shortcuts Editor
- Troubleshooting
- Troubleshooting Git
Developers
- Developer Guide
- Architecture
- Project Layout
- Backend
- How Folder Watching Works
- Folder Watching Bugs We Fixed
- How Workspace Files Work
- How the Preview Scheme Works
- Backend Services
- How Terminal Features Work
- Terminal Bugs We Fixed
- Frontend
- How the Rich Markdown Editor Works
- Rich Markdown Bugs We Fixed
- Git Menu Links
- Menu Keys and Routing
- Frontend Modules
- Blame Bugs We Fixed
- Project Color And Title Bar
- One Diff View
- Diff Bugs We Fixed
- Merge Tool Layouts
- Merge Tool Bugs We Fixed
- Color Theme Bugs We Fixed
- How the Connected Diff Works
- Rounded Panels Bugs We Fixed
- Update Bugs We Fixed
- Status Bar Bugs We Fixed
- MCP and CLI Bugs We Fixed
- Repository Actions Bugs We Fixed
- How the Changes Tab Works
- CodeMirror Patterns
- How the Cursor Works
- How Editor Features Work
- How the Path Bar Works
- Commands and Events
- Settings Reference
- Commands Workspace and Changes
- Commands Branches and Remotes
- Commands History and Extras
- Commands App and Tools
- Testing
- Test Suites
- Debugging
- Debugging with MCP
- Measuring Setting Memory
- How Terminal Memory Is Measured
- How Markdown Diagrams Work
- Releases and CI
- Publishing the Wiki
- Versioning and Changelog
- Browser Version Packages
- Browser Release Checks
- Docker Image
- Platforms and Signing
- Windows Support
- Windows Bugs We Fixed
- Windows MCP and CLI
- Docs and Screenshots
- UI Library
- UI Library MCP
- UI Library Bugs
- UI Library Migration
- Contributing
How features work
- Welcome screen
- Workspaces and folders
- Files panel
- File operations
- File icons
- Editor and tabs
- Pin, reorder and wrap tabs
- Single tab title
- Split editor
- New File and unsaved changes
- Unload hidden tabs
- Editing code
- Code appearance
- Markdown editor
- Image and PDF preview
- Search Everywhere
- Recent Files
- Navigation Bar
- Find and replace
- Changes and commits
- Sign-in prompts
- Commit box layout
- Repository actions
- Commit options
- Ignoring files
- Diffs
- Inline diffs
- Staging view
- Revert a change
- Resolving conflicts
- Merge tool
- Blame
- History and log
- Merge commits
- Commit tabs
- Branches and tags
- Branches popup
- Remotes
- Stashes
- Shelf
- Git menu
- Git dialogs
- Interactive rebase
- Worktrees
- AI agents
- AI usage
- Keep computer awake
- AI tasks
- Submodules
- Git LFS
- GitHub account
- Git Console
- Back and Forward
- Integrated terminal
- Scripts tool window
- Menu bar
- Settings
- Search in Settings
- Color themes
- Rounded panels
- Updates and release channels
- Status bar and help links
- Notifications
- Memory readout and memory log
- Clear Cache
- MCP server and command line tool
- git mergetool mode