fix(server): enable git core.longpaths on Windows #6327
ClosedThat1Drifter(GitHub profile, opens in a new tab)wants to merge 6 commits into
main fromrefs/pull/6327/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/vcs/GitVcsDriverCore.ts line 129OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -100,0 +109,21 @@109+ * into a worktree, and fail to be removed afterwards. Removal is the worse half:110+ * git drops its administrative record before deleting files, so a partial delete111+ * strands the directory where `git worktree list` can no longer see it.112+ *113+ * Passed per invocation through `GIT_CONFIG_*` rather than argv so the config114+ * reaches every git subcommand without changing the command line, and nothing is115+ * written to the user's config. Appended after any entries the caller already116+ * set so an inherited `GIT_CONFIG_COUNT` keeps working.117+ *118+ * A `GIT_CONFIG_COUNT` that is not a count is left alone. Git rejects a bogus119+ * value itself, and appending to it would overwrite the caller's first entry and120+ * turn that loud failure into a silently different config.121+ */122+export const windowsLongPathConfigEnv = (123+ platform: NodeJS.Platform,124+ env: NodeJS.ProcessEnv,125+): NodeJS.ProcessEnv => {126+ if (platform !== "win32") {127+ return {};128+ }129+ const inherited = env.GIT_CONFIG_COUNT?.trim();
- apps/server/src/vcs/GitVcsDriverCore.ts line 817OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -751,11 +803,15 @@751803 }),752804 ),753805 );806+ const spawnEnv = {807+ ...process.env,808+ ...input.env,809+ ...trace2Monitor.env,810+ };754811 const child = yield* commandSpawner755812 .spawn(756813 ChildProcess.make("git", commandInput.args, {757814 cwd: commandInput.cwd,758815 env: {759- ...process.env,760- ...input.env,761- ...trace2Monitor.env,816+ ...spawnEnv,817+ ...windowsLongPathConfigEnv(hostPlatform, spawnEnv),
juliusmarminge added labelsmacroscope-review
- apps/server/src/vcs/VcsProcess.ts line 149OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -115,0 +129,21 @@129+ * written to the user's config. Appended after any entries the caller already130+ * set so an inherited `GIT_CONFIG_COUNT` keeps working.131+ *132+ * A `GIT_CONFIG_COUNT` that is not a count is left alone. Git rejects a bogus133+ * value itself, and appending to it would overwrite the caller's first entry and134+ * turn that loud failure into a silently different config.135+ */136+export const windowsLongPathConfigEnv = (137+ platform: NodeJS.Platform,138+ env: NodeJS.ProcessEnv,139+): NodeJS.ProcessEnv => {140+ if (platform !== "win32") {141+ return {};142+ }143+ const countKey =144+ Object.keys(env).find((key) => key.toUpperCase() === "GIT_CONFIG_COUNT") ?? "GIT_CONFIG_COUNT";145+ const inherited = env[countKey];146+ if (147+ inherited !== undefined &&148+ inherited !== "" &&149+ /^[ \t\r\n\v\f]*\+?\d+/.exec(inherited)?.[0] !== inherited
juliusmarminge closed this
Sign in to join this conversation.
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
8423df9d-785a-43f1-9722-9f30d77c0498📥 Commits
Reviewing files that changed from the base of the PR and between b879749dfb5fecc536d4ff15174d9151e1efa1d0 and bf36ad605166751b2f0b9ba24382bce3aba6ca7a.
📒 Files selected for processing (2)
apps/server/src/vcs/GitVcsDriverCore.test.tsapps/server/src/vcs/VcsProcess.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
Windows Git subprocesses now merge host and caller Git configuration, then apply
core.longpaths=true. Tests cover configuration merging, platform behavior, and checkpoint restoration for a long path.Changes#
Windows Git long-path support
apps/server/src/vcs/VcsProcess.ts,apps/server/src/vcs/GitVcsDriverCore.test.tscore.longpaths=truewhen the inherited count is accepted. Tests cover casing, precedence, and malformed counts.apps/server/src/vcs/GitVcsDriverCore.ts,apps/server/src/vcs/VcsProcess.ts,apps/server/src/vcs/VcsProcess.test.tsapps/server/src/vcs/GitVcsDriver.test.tsPriority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
t3dotgg,cdvolvikMerge Risk: ⚪ Minimal · up to
bf36aThe change enables Windows Git long-path support without modifying user configuration. No concrete merge-blocking issue remains; merge after normal checks pass.
Security Architecture Review#
Security architecture risk: 🔵 Low · up to
bf36aThe change is narrowly scoped to Windows Git subprocesses and does not persist configuration or change command permissions. No introduced security issue was established, but downstream environment handling and upstream authorization were not fully verified.
Retained concerns No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#635] requires Windows worktree creation to support repository paths beyondMAX_PATH.GitVcsDriverCorenow passesgitCommandEnvto Git child processes. On Windows,gitCommandEnvappends…VcsProcessandGitVcsDriverCoreapply per-invocation Git configuration for Windows. The tests verify Windows behavior, non-Windows behavior, inh…✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.