Skip to content

fix(git): stop native checkout/pull from running against the user's p… - #282

Open
Spelt wants to merge 1 commit into
HashLoad:mainfrom
Spelt:fix/native-git-parent-repo
Open

fix(git): stop native checkout/pull from running against the user's p…#282
Spelt wants to merge 1 commit into
HashLoad:mainfrom
Spelt:fix/native-git-parent-repo

Conversation

@Spelt

@Spelt Spelt commented Aug 26, 2026

Copy link
Copy Markdown

Project repo

doClone and getWrapperFetch remove the module's .git link file when they finish, but CheckoutNative and PullNative later run plain "git checkout -f " / "git pull --force" with cwd set to modules/. Without a .git there, git walks up the directory tree, discovers the user's own project repository, and runs the command against it — silently switching the user's project to the dependency's branch (e.g. from development to master) and pulling it.

Fix:

  • CheckoutNative and PullNative now write the .git link file (pointing at the cache git dir) before running, and remove it afterwards, same as getWrapperFetch already does for reset/fetch.
  • runCommand sets GIT_CEILING_DIRECTORIES to the modules dir so repo discovery can never escape into an enclosing repository, even if a .git link is missing for any other reason.

…roject repo

doClone and getWrapperFetch remove the module's .git link file when they
finish, but CheckoutNative and PullNative later run plain "git checkout
-f <ref>" / "git pull --force" with cwd set to modules/<dep>. Without a
.git there, git walks up the directory tree, discovers the user's own
project repository, and runs the command against it — silently switching
the user's project to the dependency's branch (e.g. from development to
master) and pulling it.

Fix:
- CheckoutNative and PullNative now write the .git link file (pointing
  at the cache git dir) before running, and remove it afterwards, same
  as getWrapperFetch already does for reset/fetch.
- runCommand sets GIT_CEILING_DIRECTORIES to the modules dir so repo
  discovery can never escape into an enclosing repository, even if a
  .git link is missing for any other reason.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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