Repository navigation
How Merge Commits Work
A merge commit has two or more parents. This page explains how the Log's commit details list a merge's files: the files that differ from every parent by default, or the changes to each parent. For the user side, see Merge Commits.
The Log used to diff every commit against its first parent only. For a merge that shows everything the merged branch brought in, which can be dozens of files, and hides the question people usually ask: which files did the merge have to combine, and how were the conflicts resolved? A list of the files the merge had to combine answers this, and the Log now shows that list.
log::details (src-tauri/src/git/log.rs) diffs the commit's tree against each parent's tree with git2, with rename detection. git/commit_files.rs holds the pieces:
-
changed_files(repo, parent, tree): theChangedFilelist against one parent (none for a root commit). -
merged_files(first, later): the files of the first list whose path is also in every later list. A file is in it only when the merge result differs from all parents, the same rule asgit diff-tree -c --name-only.
CommitDetails carries files (against parent 1, as before), laterParentFiles (one list per later parent, empty for a normal commit) and mergedFiles.
flowchart LR
C[merge commit tree] --> P1[diff with parent 1]
C --> P2[diff with parent 2]
P1 --> F[files]
P2 --> L[laterParentFiles]
F --> M[mergedFiles: in every list]
L --> M
On the page, src/lib/log/commitFiles.ts turns the details into rows. commitFileRows(details, view) gives a normal commit's files; for a merge it gives mergedFiles in the merged view, or a heading per parent followed by that parent's files in the parents view. Each file row carries its parentIndex. Its key is the path for parent 1 and index + NUL + path for later parents, so the same file under two parents stays two rows, and switching views keeps a parent 1 selection.
CommitLoader (commitLoader.svelte.ts) keeps mergeView, the selectedKey and the derived rows. loadDiff calls getCommitFileDiff(..., parentIndex), which reaches diff::commit_file with that parent. The diff's left label comes from parentLabel: Parent, or Parent 2 for a merge's second. The binary preview of a later parent uses that parent's full id, which the gmpreview scheme accepts.
CommitFileList.svelte draws the caption (with Show parents or Show both sides), the list and the empty state with Show changes to parents.
A file of the merged view also loads its diff against parent 2 (CommitLoader.loadDiff, with that parent's own rename source from laterParentFiles). When both diffs are text Diff layout is side by side and settings.mergeDiffPanes is "three" (Settings > Git, or the toolbars' Three panes button through diff/diffPanes.ts), CommitDetails shows ThreePaneDiff.svelte instead of DiffView: the library's MergeFrame with three read-only editors built by ThreeWayEditors (diff/threeWayEditors.svelte.ts).
The pure parts are in diff/threeWay.ts. Each parent's backend hunks against the result become ThreeWayChanges; a change whose result lines touch the other parent's changes is a conflict. resultMarks merges both parents' result ranges for the middle pane, parentMarks adds the changed words, and parentAnchors maps each parent's lines to the result's. The result is the hub for scrolling: a scrolled pane's center line is mapped to the result, then to the other parent, with the merge tool's mapLine, lineAtCenter and scrollToLine. The bands come from the merge tool's span, and MergeFrame draws them without buttons when it gets no onapply.
| File | What it does |
|---|---|
src-tauri/src/git/commit_files.rs |
ChangedFile, changed_files, merged_files
|
src-tauri/src/git/log.rs |
details: the lists for every parent |
src-tauri/src/git/diff.rs |
commit_file with a parent index |
src/lib/log/commitFiles.ts |
Rows, keys, selection and captions |
src/lib/log/commitLoader.svelte.ts |
Selection, view and the diff against the chosen parent |
src/lib/log/CommitFileList.svelte |
The list, its caption and empty state |
src/lib/diff/threeWay.ts, threeWayEditors.svelte.ts, ThreePaneDiff.svelte
|
The 3-pane diff |
- Files that differ from every parent, not "conflicts". Git keeps no record of conflicts, so no tool can list them exactly. The rule matches git's combined diff, and the UI says "Changed on both sides" because a file both branches changed in different places is listed too.
- The merged view is the default for merges. It answers the common question and is short; the per-parent view is one click away.
- Every list is sent at once. A merge's lists come in one call so switching views needs no round trip. Each list is a tree diff git2 does quickly; a normal commit sends empty extra lists.
- Parent 1 for a merged file's diff. It shows what the other branch and the resolution brought in. The per-parent view gives the diff against parent 2.
-
src-tauri/src/git/commit_files_tests.rs: a merge where both sides changed one file, a resolved conflict, a merge that took each file from one side (no merged files), normal and root commits, andcommit_fileagainst parent 1, parent 2 and a missing parent. -
src/lib/log/commitFiles.test.ts: rows in both views, keys per parent, picking the selection, labels and captions. -
src/lib/diff/threeWay.test.ts: change types, conflicts where both parents changed the same lines, merged result marks, changed words and anchors.
- A change to how
CommitDetailslists files updatescommitFiles.tsand both test files. - Retake
merge-commit-files.pngwhen the merge view looks different. The docs demo's merge combinessrc/catalog.tsfrom both branches (scripts/make-docs-demo.sh), so the shot shows three panes.
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