Inspection
Commit overlap
4 min read
Before reorganizing a branch with interactive rebase, it's worth knowing which commits depend on each other. Commit overlap compares a branch's commits with one another and tells you:
- which ones touch the same lines (≡): swapping their order conflicts, and they're candidates for squash or fixup;
- which ones touch adjacent lines (≈): swapping their order will probably conflict;
- which ones touch only the same files (◦), in other parts: they can be reordered without conflicts;
- which ones conflict with the base (!): a rebase onto the base should stop at them.
With this you decide what to combine, what to reorder and what can be split off into a branch of its own.
- Menu of a branch (local or remote): Commit overlap of <branch>…
- Palette (Ctrl+P): "Commit overlap of the current branch" ("Which commits of <branch> touch the same lines or files").
- Right-click the
feature/checkoutbranch and choose Commit overlap of feature/checkout…. - The screen opens in the central area and reads the commits ("Reading the branch commits…"). The progress bar has Cancel.
- Check the base under against. Versora picks it on its own:
- the branch below, if the branch is part of a stack;
- Gitflow's
develop, for a feature branch; - otherwise,
main,master,developortrunk(or the equivalent underorigin/). To change it, choose another local or remote branch in the list. The analysis starts over.
- Read the summary: how many commits the branch has since the merge base with the base, and whether any of them is likely to conflict in a rebase onto it.
- In the list (from newest to oldest), choose the Focused commit (●). The marks on the other rows show each commit's relation to it: ≡, ≈ or ◦. The ! mark indicates a conflict with the base. Hover over a mark to see the files.
- On the right, see the focused commit's sections:
- Same lines (N commits): "They touch what this commit wrote (or it touches theirs): swapping the order conflicts. Candidates for squash or fixup.";
- Adjacent lines (N commits): "Changes right next to this commit's: swapping the order will probably conflict.";
- Only the same files (N commits): "Same file, other parts: they can be reordered without conflicts.";
- Conflicts with <base>: "The base changed the same places after the branch left it: a rebase should stop at this commit.".
- Under Suggestions, see the "Together (N commits):" groups, which share lines and should travel together, and how many commits share no lines with any other.
- If the branch is the current one, click Interactive rebase… ("Opens the interactive rebase of these commits, with the focused commit and the same-line ones highlighted") to reorganize it. See Interactive rebase.
The branch's commits since the merge base with the base are read in order, along the branch's main line and without merges, with the diff without context:
# the branch's commits, from oldest to newest, with the diff of each one
git log --first-parent --no-merges --reverse -n 400 -U0 --no-color --no-ext-diff --no-textconv -M -p <merge-base>..<branch>
# what the base changed since the branch left it
git diff -U0 --no-color --no-ext-diff --no-textconv -M <merge-base> <base>
For each file, Versora keeps the line ranges each commit wrote and shifts them through the following commits (lines inserted or removed above push the ranges). A range that lands on top of another commit's range is "same lines"; right next to it, "adjacent lines". In both cases, git's three-way merge conflicts when the order is swapped. The base's changes since the merge base go into the same computation, as if they were one more commit, and that's how the app predicts the conflicts with the base.
Nothing is changed in the repository: the analysis only reads.
There's nothing to undo. An Interactive rebase… opened from here follows the normal rebase rules, with Ctrl+Z.
- "<branch> has no commits of its own since it left <base>.": there's nothing to analyze. Check the base.
- "N merges on the branch line are left out of the analysis": merges in the middle of the branch are left out.
- "Long branch: only the newest N of M commits were analyzed (conflicts with the base are skipped).": the analysis goes up to 400 commits.
- "No two commits touch the same lines: the order can be changed freely.": the commits are independent.
- "This commit touches nothing the other commits of the branch touch: it can be reordered, moved to another branch or sent on its own.": the focused commit is independent.
- "<branch> and <base> have no history in common.": choose another base.
- "In detached HEAD there's no current branch": the palette makes the command unavailable without a branch.
- "Analysis canceled.": you canceled the reading.
This analysis has no preference of its own and no company policy key.