Skip to content

fix(git): enable long paths when creating Windows worktrees - #15786

Closed
hwantage wants to merge 1 commit into
stablyai:mainfrom
hwantage:fix/windows-worktree-long-paths
Closed

hwantage wants to merge 1 commit into
stablyai:mainfrom
hwantage:fix/windows-worktree-long-paths

Conversation

@hwantage

@hwantage hwantage commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Windows can reject deeply nested checkout paths. Git for Windows can be installed with long-path handling disabled, so ordinary users can hit this while creating a worktree in a deep directory. When Orca creates a local worktree on Windows, it now asks Git to enable long-path handling for that one git worktree add command. Users do not need to discover and change their global Git settings to use a core Orca workflow.

What Changed

  • Updated src/main/git/worktree.ts so native Windows git worktree add is invoked as git -c core.longpaths=true worktree add ....
  • Kept the option before the worktree subcommand because -c is a global Git option.
  • Excluded WSL-routed Git (wslDistro), which runs in the Linux guest rather than against native Windows paths.
  • Added unit coverage in src/main/git/worktree-add-creation-config.test.ts for both native Windows and WSL command construction.

Why

The worktree checkout can exceed the legacy Windows path limit when the workspace root, branch name, and tracked file path are combined. This can affect users with a standard Git for Windows installation because the current manual remedy is a git config change. Since worktree creation is a core Orca workflow, failing before the worktree is created is a high-impact failure. Applying core.longpaths=true on the command avoids persistent changes to global or repository Git configuration and is compatible with Orca's Git 2.25 baseline because it uses Git's command-line configuration option rather than the newer indexed environment-config protocol.

Linked Issue

Fixes #15785

Visual Proof

image

Testing

  • Manually verified on native Windows.
  • Automated tests added/updated.

Commands run:

  • pnpm exec vitest run --config config/vitest.config.ts src/main/git/worktree-add-creation-config.test.ts
  • git diff --check
  • pnpm exec oxlint src/main/git/worktree.ts src/main/git/worktree-add-creation-config.test.ts
  • pnpm exec tsc --noEmit -p config/tsconfig.node.json --composite false

AI Disclosure

Developed with OpenAI Codex (GPT-5).

Review

  • Cross-platform: The command option is gated by process.platform === 'win32'; macOS and Linux keep the existing argv.
  • WSL: Calls with wslDistro keep the existing Linux Git argv.
  • SSH / remote: Unchanged. This path handles local worktree creation; remote hosts keep their existing execution paths.
  • Git compatibility: -c core.longpaths=true is placed before the subcommand and avoids reliance on GIT_CONFIG_COUNT support.
  • Security / configuration: No user or repository Git configuration is written.
  • Performance: One static Git option is added only to native Windows worktree creation.

Agent skill upstream boundary

  • Not applicable; this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused.
  • I explained what changed and why, including ELI5.
  • Visual proof is N/A because there is no UI change.
  • Self-reviewed for correctness, security, and performance.
  • Cross-platform, WSL, SSH, and remote impact considered.
  • Full pnpm lint, pnpm typecheck, pnpm test, and pnpm build were not run locally; CI should cover the remaining checks.

Author

Github: @hwantage

@coderabbitai

coderabbitai Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3d13db27-d812-465f-a5ce-0cb43b7808b4

📥 Commits

Reviewing files that changed from the base of the PR and between 4fd93ea and f269bf2.

📒 Files selected for processing (2)
  • src/main/git/worktree-add-creation-config.test.ts
  • src/main/git/worktree.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

On native Windows, performAddWorktree prefixes the Git worktree command with -c core.longpaths=true. WSL and other environments retain their existing command arguments. Tests verify the native Windows option, WSL distro and timeout settings, and the absence of the Windows-only option in WSL.

Merge Risk: ⚪ Minimal · up to f269b

This narrowly enables long-path handling for native Windows worktree creation without changing persistent Git configuration or WSL behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes enabling long-path handling for Windows Git worktree creation.
Description check ✅ Passed The description covers the required sections, explains the change and rationale, links issue #15785, and documents testing and compatibility considerations.
Linked Issues check ✅ Passed The implementation satisfies issue #15785 by enabling long paths only for native Windows worktree creation while preserving WSL and remote behavior.
Out of Scope Changes check ✅ Passed The changes are limited to native Windows worktree command construction and focused unit tests, with no unrelated scope identified.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hwantage

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hwantage

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@nwparker

Copy link
Copy Markdown
Contributor

Thank you for this, @hwantage — you found a real bug and the usage: git [-v | --version] [-h | --help] [-C ] [-c =]
[--exec-path[=]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=] [--work-tree=] [--namespace=]
[--config-env==] []

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
restore Restore working tree files
rm Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
diff Show changes between commits, commit and working tree, etc
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status

grow, mark and tweak your common history
branch List, create, or delete branches
commit Record changes to the repository
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
reset Reset current HEAD to the specified state
switch Switch branches
tag Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help ' or 'git help '
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system. approach is exactly right: command scope only, so no user or repo config gets touched.

One logistics note: fork PRs in this repo only run track-community-pr, not the full CI matrix, so I've carried your commit onto an internal branch to get it through the whole pipeline. Your authorship is preserved on the original commit — I only added a second commit on top.

What that follow-up commit covers:

  • Sparse worktrees: addSparseWorktree calls addWorktree with noCheckout=true, so the flag was landing on a worktree add --no-checkout that writes no files. The sparse-checkout set and checkout <branch> calls that actually materialize the tree now carry it too.
  • SSH hosts: remote creation builds its own argv in src/relay/git-handler-worktree-ops.ts, keyed off the execution host's platform rather than the client's.
  • Switched the predicate from !options.wslDistro to the cwd, since a C:\... path can still be served by host git.exe even with a distro configured.

New PR: #15866. Leaving this one open so it stays linked — thanks again!

@hwantage

Copy link
Copy Markdown
Contributor Author

@nwparker
Thank you for the follow-up and handling the extra cases! Looks great.👍

@nwparker

Copy link
Copy Markdown
Contributor

Landed as #15866 — thank you @hwantage! 🎉

Your commit was cherry-picked and the squash carries a Co-authored-by trailer, so your authorship is preserved. The separate PR was needed because fork PRs here only run track-community-pr.

This one got real Windows hardware verification before merge: the Filename too long failure was reproduced without the fix and confirmed resolved with it, and core.longpaths was confirmed to land in no global or system config. One finding worth knowing — core.longpaths does not raise the worktree root path ceiling (a 215-char root works, 216 fails with fatal: '$GIT_DIR' too big), so deep files inside a short root are what this fixes. That's documented in the merged PR. Thanks for the fix.

@nwparker nwparker closed this Aug 23, 2026
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]: [Windows] Worktree creation fails with "Filename too long" for deep paths

2 participants