Skip to content

perf: eliminate redundant git spawns in ref resolution, inferParent, and absorb amend - #199

Merged
andyrewlee merged 1 commit into
mainfrom
advisor/026-git-spawn-elimination
Sep 28, 2026
Merged

andyrewlee merged 1 commit into
mainfrom
advisor/026-git-spawn-elimination

Conversation

@andyrewlee

Copy link
Copy Markdown
Owner

Summary

Cuts redundant git subprocess spawns in four hot paths, no behavior change:

  • localBranchRef: full 40-hex SHAs now skip the show-ref --verify probe outright — a hex value can never be a branch name. The doc comment already claimed this; the code now matches.
  • mergedBranches: ChangesContainedIn call sites pass refs/heads/<name> instead of a bare name, skipping a probe per unmerged branch.
  • inferParent: the two unbounded rev-list walks (AncestorSet for the adopted branch and the trunk) are replaced by two bounded for-each-ref --merged scans (MergedInto). Equivalence: tip(c) is an ancestor of name iff c ∈ MergedInto(name); merged-into-trunk likewise. The TipsFor existence read is subsumed — a deleted branch just fails the merged test.
  • AmendTipWithPatch: the RevParse + rev-list --parents + log --format trio collapses into one log -1 --format=%H%x00%P%x00%an%x00%ae%x00%aD%x00%B read — a 3→1 win per absorb target.

Test plan

  • New TestLocalBranchRefSkipsProbeForQualifiedAndSHA (git shim argv log): zero show-ref spawns for SHA/refs/ args
  • TestTrackBranchInferParentUsesMergedRefScans replaces the scoped-TipsFor pin: asserts 2 MergedInto, 0 TipsFor, 0 AncestorSet
  • make test-fast, go test ./internal/git ./internal/stack green
  • make ci green

@andyrewlee
andyrewlee merged commit 8686742 into main Sep 28, 2026
2 of 3 checks passed
@andyrewlee
andyrewlee deleted the advisor/026-git-spawn-elimination branch September 29, 2026 05:32
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