Repository navigation
Conversation
… repository isRepo() used rev-parse --is-inside-work-tree, which is true for any subdirectory of any worktree. A repoDir placed inside an unrelated outer repository therefore skipped initialization: ensureRepo wrote core.autocrlf and the sync identity into the outer repo, and bootstrap rewrote its origin and committed into its history (observed live: a workspace repo's origin and identity rewritten plus a stray whole-tree commit). isRepo() now compares rev-parse --show-toplevel against repoDir by realpath identity (path.resolve fallback for non-existent paths, both sides normalized identically). A repoDir that is merely a subdirectory of an outer repo takes the init path and gets its own dedicated repository; the outer repo's config, origin, and history stay untouched. Correctly-placed repoDirs behave exactly as before. Tests: three real-git regressions (outer-worktree bootstrap isolation, root-only isRepo semantics, idempotency), all mutation-checked (reverting the predicate fails all three); the two scripted bootstrap tests updated to the new rev-parse call. Gates: 130 tests / 128 pass / 0 fail / 2 env-skips; typecheck and typecheck:ci clean; lint 4 pre-existing warnings; self-contained, artifacts, five-language readmes green. CHANGELOG [Unreleased] and all five READMEs updated.
…poDir) Arm A round-1 MINOR: the raw-string-comparison mutant survived the shipped tests. Two regressions now kill it: a case-variant repoDir at the true root (Windows) and a directory-linked repoDir resolving to its target root (junction on Windows, symlink on POSIX). Suite: 132 tests / 130 pass / 0 fail / 2 env-skips; mutation verified both arms, restore hash-equal.
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.
Checklist
pnpm run typecheck && pnpm run typecheck:ci && pnpm test && pnpm run verify:self-contained && pnpm run verify:artifacts && pnpm run check:readmes && pnpm pack)[Unreleased]worktree,isRepo,hijack,outerDescription
GitBackend.isRepo()decides whetherensureRepo()may skip initialization. It usedgit rev-parse --is-inside-work-tree, which returns true for any subdirectory of any worktree — not just the repository root. WhenrepoDirsits inside an unrelated outer git repository (for example a sync directory placed under a project checkout),isRepo()returned true, initialization was skipped, and every subsequent write landed in the outer repository:ensureRepo()wrotecore.autocrlfand the sync commit identity into its config,bootstrap()rewrote itsoriginremote, and subsequent sync checkpoints committed into its history. Observed live: an unrelated workspace repository had its origin and identity rewritten and gained a stray whole-tree commit, silently redirecting every session's pushes to the wrong remote.The fix makes
isRepo()mean what its callers need: repoDir is itself the root of a git worktree. It comparesgit rev-parse --show-toplevelagainstrepoDirby realpath identity (both sides normalized;path.resolvefallback when a path does not exist, applied identically to both sides). ArepoDirthat is merely a subdirectory of an outer repository now takes the init path and gets its own dedicated repository — the outer repository's config, origin, and history stay untouched. A correctly-placedrepoDirbehaves exactly as before (toplevel equals repoDir).User-visible effect: placing the sync directory inside an existing checkout no longer hijacks that checkout; the plugin initializes its own mirror repository as designed. No configuration change, no API change.
Verification
Commands run on Windows (Node v24.21.0, git 2.56.0), all at the PR commit:
pnpm test— 132 tests, 130 pass, 0 fail, 2 skipped (the two pre-existing Windows symlink-privilege skips). Five new real-git regressions intest/repo-isolation.test.mjs: bootstrap inside an outer worktree leaves the outer origin/identity/HEAD/commit-count untouched and creates the dedicated inner repo;isRepois true only at a worktree root; a second bootstrap is idempotent and still leaves the outer untouched; a case-variant repoDir path at the true root is recognized (Windows); a directory-linked repoDir resolves to its target root (junction on Windows, symlink on POSIX). The two scriptedgit.test.mjsbootstrap tests are updated to the newrev-parse --show-toplevelcall (sequences otherwise unchanged, assertions strengthened).isRepo()to--is-inside-work-treefails all three isolation regressions (the hijack reproduces); dropping the realpath normalization fails the two normalization regressions; restoring the fix returns them to green, hash-verified.pnpm run typecheckandpnpm run typecheck:ci— clean.pnpm run lint— 4 warnings, 0 errors (all pre-existing, none in the changed code).pnpm run verify:self-contained,pnpm run verify:artifacts,pnpm run check:readmes,pnpm pack— all pass.CHANGELOG
[Unreleased]and the security-boundaries section of all five READMEs document the dedicated-repository guarantee.