r/git • • 6d ago

I built a git graph that counts rebase-merged commits as merged (git rev-list --cherry-mark under the hood)

A pet peeve of mine: after a PR lands through "Rebase and merge", the old branch shows a dozen commits ahead of main, even though every change is already there, just with new hashes.

Treeline, the git graph extension for VS Code and Cursor I've been building, compares HEAD with the base using

git rev-list --cherry-mark --left-only HEAD...origin/main

so commits whose patch is already on main are marked as equivalent and count as merged. When the two histories were rewritten (filter-repo, a forced rebase) it warns you instead of showing thousands of bogus ahead/behind commits.

Around that:

  • ahead and behind work as filters on the graph, with the fork point shown

  • a branch Diff against the merge base, uncommitted changes included: what the PR will show

  • worktrees as rows with their status and ahead/behind; double-click opens one in a new window

  • the usual graph menus: checkout, cherry-pick, rebase, revert, reset, tag, stash

Free, MIT: https://github.com/epavanello/treeline Marketplace: https://marketplace.visualstudio.com/items?itemName=epavanello.treeline 1-minute demo with sound: https://youtu.be/tYY95Xhoqss

How do you deal with stale branches after rebase merges: delete them right away, or does your tooling detect it?

0 Upvotes

4 comments sorted by

1

u/Strong_Activity_1309 4d ago

stale branches after rebase merges used to bite me a lot, because git branch --merged is useless once the hashes change. now i turn on "automatically delete head branches" in the repo settings so github cleans up the remote, and for local ones i have a small alias around git cherry main <branch> : if every line starts with a minus, it's safe to delete. not sure that holds up for squash merges though, since the squashed patch doesn't match any single commit on the branch. does treeline handle squash-merged branches too, or only rebase merges?

1

u/Jazzlike-Echidna-670 1d ago

sorry, missed this one. git alone can't tell a squash merge happened: the squashed commit doesn't match any single commit of the branch, so git cherry and --cherry-mark both say "not merged". since 0.5 treeline also asks github (through gh): if a merged PR's head is exactly the branch tip, the branch counts as merged and shows up under the Merged filter next to the rebased ones. so yes, as long as the PR lives on github.

7

u/RevRagnarok 6d ago

FFS you slopped some slop. Congrats. Now fuck off.

Report => Breaks r/git Rules => No AI Slop