fix(git): cache unsupported capabilities per host (#8109)
* fix(git): cache unsupported capabilities per host Old Git worktree, ref-search, and merge-tree fallbacks retried unsupported flags on recurring operations, flooding subprocess traces. Centralize capability probing per native, WSL, and SSH execution host, coalesce concurrent probes, and retry periodically for in-place Git upgrades. * fix(git): recognize real old-Git merge-tree rejection * test(git): enforce real binary compatibility matrix * fix(ci): preserve Git compatibility test ownership * fix(git): retain supported capability state
This commit is contained in:
@@ -10,6 +10,7 @@ import * as path from 'node:path'
|
||||
import { decodeGitCQuotedPath } from '../shared/git-cquoted-path'
|
||||
import { isBinaryBuffer } from '../shared/binary-buffer'
|
||||
import type { GitLineStats } from '../shared/git-uncommitted-line-stats'
|
||||
export { isUnsupportedWorktreeListZError } from '../shared/git-worktree-command-capabilities'
|
||||
|
||||
export function parseBranchStatusChar(char: string): string {
|
||||
switch (char) {
|
||||
@@ -134,36 +135,6 @@ export function parseBranchDiff(
|
||||
|
||||
// ─── Worktree parsing ────────────────────────────────────────────────
|
||||
|
||||
function getErrorText(error: unknown): string {
|
||||
if (typeof error === 'object' && error !== null) {
|
||||
const parts: string[] = []
|
||||
if ('message' in error && typeof error.message === 'string') {
|
||||
parts.push(error.message)
|
||||
}
|
||||
if ('stderr' in error && typeof error.stderr === 'string') {
|
||||
parts.push(error.stderr)
|
||||
}
|
||||
return parts.join('\n')
|
||||
}
|
||||
return String(error)
|
||||
}
|
||||
|
||||
function getErrorCode(error: unknown): string | undefined {
|
||||
return typeof error === 'object' && error !== null && 'code' in error
|
||||
? String((error as { code?: unknown }).code)
|
||||
: undefined
|
||||
}
|
||||
|
||||
export function isUnsupportedWorktreeListZError(error: unknown): boolean {
|
||||
// `-z` is this command's only flag older Git (<2.36) lacks, so its usage exit
|
||||
// 129 signals the rejection in any locale; key for SSH remotes on old Git.
|
||||
if (getErrorCode(error) === '129') {
|
||||
return true
|
||||
}
|
||||
|
||||
return /(?:unknown|invalid|unrecognized) (?:switch|option).*`?-?z'?/i.test(getErrorText(error))
|
||||
}
|
||||
|
||||
export function parseWorktreeList(
|
||||
output: string,
|
||||
options: { nulDelimited?: boolean } = {}
|
||||
|
||||
Reference in New Issue
Block a user