mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
fix(git): enable Windows long paths for worktree creation (local, sparse, and SSH hosts) (#15866)
Co-authored-by: hwantage <hwantagexsw2@gmail.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { windowsLongPathGitArgs } from './windows-long-path-git-args'
|
||||
|
||||
describe('windowsLongPathGitArgs', () => {
|
||||
it('enables long paths for a Windows drive path', () => {
|
||||
expect(windowsLongPathGitArgs('C:\\Users\\dev\\repo', 'win32')).toEqual([
|
||||
'-c',
|
||||
'core.longpaths=true'
|
||||
])
|
||||
})
|
||||
|
||||
it.each(['darwin', 'linux'] as const)('returns nothing on %s', (platform) => {
|
||||
expect(windowsLongPathGitArgs('/home/dev/repo', platform)).toEqual([])
|
||||
})
|
||||
|
||||
it.each(['\\\\wsl.localhost\\Ubuntu\\home\\dev\\repo', '\\\\wsl$\\Ubuntu\\home\\dev\\repo'])(
|
||||
'returns nothing for the WSL UNC path %s',
|
||||
(cwd) => {
|
||||
expect(windowsLongPathGitArgs(cwd, 'win32')).toEqual([])
|
||||
}
|
||||
)
|
||||
|
||||
it('never mutates the shared constant', () => {
|
||||
const first = windowsLongPathGitArgs('C:\\repo', 'win32')
|
||||
first.push('--bogus')
|
||||
expect(windowsLongPathGitArgs('C:\\repo', 'win32')).toEqual(['-c', 'core.longpaths=true'])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,25 @@
|
||||
import { parseWslUncPath } from './wsl-paths'
|
||||
|
||||
const WINDOWS_LONG_PATH_GIT_ARGS = ['-c', 'core.longpaths=true'] as const
|
||||
|
||||
/**
|
||||
* Global `git -c` options that let a Windows checkout exceed MAX_PATH.
|
||||
*
|
||||
* Why command scope: Git for Windows aborts deep checkouts with "Filename too
|
||||
* long" unless core.longpaths is on, and `-c` applies it to this invocation
|
||||
* only — never `--global`, `--system`, or `--local`, so no user config is
|
||||
* written. Available since Git 1.9, well under the 2.25 baseline.
|
||||
*
|
||||
* Why keyed off cwd rather than a wslDistro option: a `C:\...` cwd can still be
|
||||
* served by host git.exe even when a distro is configured, and Linux git parses
|
||||
* and ignores the key, so only a true `\\wsl.localhost\...` path opts out.
|
||||
*/
|
||||
export function windowsLongPathGitArgs(
|
||||
cwd: string,
|
||||
platform: NodeJS.Platform = process.platform
|
||||
): string[] {
|
||||
if (platform !== 'win32' || parseWslUncPath(cwd)) {
|
||||
return []
|
||||
}
|
||||
return [...WINDOWS_LONG_PATH_GIT_ARGS]
|
||||
}
|
||||
Reference in New Issue
Block a user