Skip to content

feat(repo-ledger): name branches whose changes already landed by patch content - #1

Merged
joepetjr merged 1 commit into
mainfrom
feat/squash-merged-detection
Oct 27, 2026
Merged

joepetjr merged 1 commit into
mainfrom
feat/squash-merged-detection

Conversation

@joepetjr

Copy link
Copy Markdown
Contributor

What

repo-ledger now names local branches whose changes already reached a remote default branch through a squash or rebase merge. Before this, such a branch counted only as unique, because its original commits sit on no remote ref.

  • Each branch gets unlanded_commits: the unique commits with no patch-equivalent commit on a remote default branch. The default branch is the remote's HEAD, else main, else master. The count is 0 when one commit there carries the patch of the branch's whole diff, which is what a squash merge leaves behind.
  • Each repo summary gets branches_already_landed, and the markdown report lists those branch names.
  • unique counts and at_risk are unchanged. A branch listed as already landed is still worth a git cherry -v before you delete it.

Safety

Patch text comes from git's own diff, run with --no-ext-diff --no-textconv --no-color, and log runs with --no-show-signature. That way repository config still cannot make the inventory run a command. A test configures an external diff driver, a textconv filter and a gpg program that each write a marker file, then checks that no marker appears.

Cost

Each default branch is read once, back to the common ancestor of the local branches. A full branch diff is built only when the branch's set of changed files matches a commit there. On the workspaces repo (346 local branches) a run takes about 72 s, against about 31 s for Yearend Planner plus workspaces before this change. docs/concepts.md notes this.

Known misses

  • A squash that also changed other files is missed, because the check needs an exact whole-diff match.
  • A squash whose context lines changed, because the default branch edited the same files first, is also missed.

An earlier draft matched path-limited partial diffs. It marked 2 more workspaces branches as landed, but those branches still had commits that git cherry reports as not upstream. The exact match is kept because it is the conservative choice.

Tests

66 passed locally (tools/repo-ledger/tests plus tests). New tests:

  • squash merge and cherry-pick, parametrized
  • a partly landed branch
  • a remote HEAD that is not main
  • diff driver, textconv and gpg cannot run (fails when the flags are removed)
  • the markdown line

Remote refs in tests are set with git update-ref.

…h content

A squash- or rebase-merged branch kept locally still counts as unique, because its original commits are on no remote ref. Each branch now also reports unlanded_commits: unique commits with no patch-equivalent on a remote default branch (its HEAD, else main, else master), or zero when one commit there carries the patch of the branch's whole diff. The repo summary lists those branches as branches_already_landed. Unique counts and at_risk are unchanged.

Patch text comes from git's own diff with external diff, textconv and signature checks off, so repository config still cannot run a command. Each default branch is read once and a full branch diff is built only when its file set matches a commit there.
@joepetjr
joepetjr merged commit 85b97ab into main Oct 27, 2026
4 checks passed
@joepetjr
joepetjr deleted the feat/squash-merged-detection branch October 27, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant