Skip to content

init: skip redundant tracked checkout#54

Merged
junior-ricon merged 1 commit into
mainfrom
junior/skip-redundant-tracked-checkout
Jun 22, 2026
Merged

init: skip redundant tracked checkout#54
junior-ricon merged 1 commit into
mainfrom
junior/skip-redundant-tracked-checkout

Conversation

@junior-ricon

Copy link
Copy Markdown
Contributor

Summary

modules init no longer runs git 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 den module fired den's notes post-checkout hook and produced macOS cut/grep illegal-byte-sequence warnings from locked notes state.

Changes

  • Skip checkout when current_branch == track.
  • Preserve existing behavior for detached clones and clones on another branch.
  • Add a BATS regression that installs a post-checkout sentinel hook in an already-current tracked clone and verifies modules init does not fire it.
  • Regenerate README test count from 135 to 136.

Validation

  • mise run test — 136/136
  • mise run test test/init.bats — 15/15
  • Patched direct smoke against Junior fold checkout: no illegal-byte warnings
  • codebase lint "$PWD"
  • mise exec -C "$PWD" shiv:readme@0.3.1 -- readme build --check
  • git diff --check
  • git pre-commit
  • git pre-push — warning only: fresh branch had no upstream and inherited GitHub merge commits are not all locally good-signed; Junior commit 1816f5c is good-signed

@junior-ricon
junior-ricon requested a review from quick-ricon June 22, 2026 00:40

@quick-ricon quick-ricon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial review pass: approved.

Findings: none.

What I tried to break:

  • Read the changed sync_tracked_branch path as shared architecture, not only init: this also affects tracked-module modules update no-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 branch failed because the sentinel post-checkout hook fired.
  • Ran targeted and broader validation locally in a correctly named temp worktree:
    • mise run test test/init.bats — 15/15
    • mise run test test/update.bats — 15/15
    • mise run test — 136/136
    • git diff --check origin/main...HEAD
    • codebase lint "$PWD" — all 9 rules passed when the worktree basename was modules (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 by update too. 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.

@junior-ricon
junior-ricon merged commit c16e716 into main Jun 22, 2026
2 checks passed
@junior-ricon
junior-ricon deleted the junior/skip-redundant-tracked-checkout branch June 22, 2026 15:34
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.

2 participants