Skip to content

Comments

fix: prevent shadow git from inheriting global init.templateDir#11630

Draft
roomote[bot] wants to merge 1 commit intomainfrom
fix/shadow-git-init-template-v2
Draft

fix: prevent shadow git from inheriting global init.templateDir#11630
roomote[bot] wants to merge 1 commit intomainfrom
fix/shadow-git-init-template-v2

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 20, 2026

Opened by @roomote on behalf of Hannes Rudolph

Related GitHub Issue

Closes: #8628

Roo Code Task Context (Optional)

Rebased version of #8629, which was closed due to inactivity but is still relevant per community feedback.

Description

This PR fixes an issue where shadow git repositories unintentionally inherit the user's global init.templateDir configuration, causing unwanted hooks (like pre-commit hooks) to be triggered in the shadow repository.

Key implementation details:

  • Modified createSanitizedGit() in ShadowCheckpointService.ts to strip the GIT_TEMPLATE_DIR environment variable, preventing it from leaking into the shadow git environment
  • Modified initShadowGit() to use git init --template= which explicitly prevents any template from being used during shadow repo initialization
  • Added a test to verify that no executable hooks from a template directory are copied into the shadow repository

Test Procedure

How I tested:

  1. Ran the existing test suite: cd src && npx vitest run services/checkpoints/__tests__/ShadowCheckpointService.spec.ts
  2. Added a specific test case does not apply git templates when initializing shadow repo to verify the fix
  3. All 34 tests pass successfully

How reviewers can verify:

  1. Check out this branch
  2. Run cd src && npx vitest run services/checkpoints/__tests__/ShadowCheckpointService.spec.ts
  3. Optionally, set up a global template directory with hooks and verify they are not copied to shadow repositories

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A - This is a backend fix with no UI changes.

Documentation Updates

  • No documentation updates are required.

The fix is an internal implementation detail that does not affect the public API or user-facing functionality.

Additional Notes

This is a targeted fix that prevents potential security issues and unexpected behavior when users have pre-commit hooks or other git templates configured globally. The shadow repository should be isolated from user configurations to ensure consistent behavior. This is a rebased version of #8629 applied cleanly on top of current main.

Get in Touch

Available via GitHub for any questions about this PR.


View task on Roo Code Cloud

Start a new Roo Code Cloud session on this branch

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.

[BUG] initShadowGit can use an unwanted init.templatedir

1 participant