init: skip redundant tracked checkout#54
Merged
Conversation
quick-ricon
approved these changes
Jun 22, 2026
quick-ricon
left a comment
Contributor
There was a problem hiding this comment.
Adversarial review pass: approved.
Findings: none.
What I tried to break:
- Read the changed
sync_tracked_branchpath as shared architecture, not onlyinit: this also affects tracked-modulemodules updateno-op checkouts because the helper is shared. That looks like a desirable reduction in redundant checkout hooks, and existing update behavior still passes. - Checked the preserved normalization paths: detached tracked clones still go through checkout, missing local branches still create a tracking branch, wrong current branches still checkout the target branch, upstream is still set after the skip, and remote-ahead/local-ahead/diverged logic still happens after the checkout gate.
- Verified the new regression is testing the real old failure mode: when I temporarily restored the old unconditional same-branch checkout,
init skips checkout hook when tracked clone is already on target branchfailed because the sentinelpost-checkouthook fired. - Ran targeted and broader validation locally in a correctly named temp worktree:
mise run test test/init.bats— 15/15mise run test test/update.bats— 15/15mise run test— 136/136git diff --check origin/main...HEADcodebase lint "$PWD"— all 9 rules passed when the worktree basename wasmodules(a first run in a differently named temp worktree produced only the expected caller-pwd-contract false positive from the package-name heuristic).
Surviving concerns / non-blocking notes:
- The PR title/body emphasize
modules init, but the implementation intentionally changes the shared tracked-branch helper used byupdatetoo. I think that is fine, just worth remembering when reading the scope. - Untracked-module update still has its own checkout behavior; that is outside this tracked-module no-op fix.
The design looks sound to me: skip only when already on the exact target branch, while retaining every path that needs checkout to restore branch shape or create tracking state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
modules initno longer runsgit checkout <track>when a tracked module clone is already on that branch.That avoids firing module-local checkout hooks unnecessarily during routine tracked-module refreshes. In the observed fold case, a no-op checkout of the
denmodule fired den's notespost-checkouthook and produced macOScut/grepillegal-byte-sequence warnings from locked notes state.Changes
current_branch == track.post-checkoutsentinel hook in an already-current tracked clone and verifiesmodules initdoes not fire it.Validation
mise run test— 136/136mise run test test/init.bats— 15/15codebase lint "$PWD"mise exec -C "$PWD" shiv:readme@0.3.1 -- readme build --checkgit diff --checkgit pre-commitgit pre-push— warning only: fresh branch had no upstream and inherited GitHub merge commits are not all locally good-signed; Junior commit1816f5cis good-signed