Files
orca/src/main/git/base-ref-search-selector.ts
T
Neil 8507111d87 Document Apple Git ref recovery retirement condition
Name the affected Apple Git-154 (2.39.5) build and document when corruption recovery can be retired while retaining current-Git disambiguation. Comments only; lint, formatting, and review pass.
2026-10-06 00:29:44 -07:00

24 lines
1.0 KiB
TypeScript

export function isQualifiedBaseRef(refName: string): boolean {
return refName.startsWith('refs/heads/') || refName.startsWith('refs/remotes/')
}
export function resolveBaseRefSearchSelector(fullRef: string, shortRef: string): string {
const parts = /^refs\/(heads|remotes)\/(.+)$/.exec(fullRef)
if (!parts) {
return fullRef
}
const namespaceName = `${parts[1]}/${parts[2]}`
const naturalName = parts[2]
// Apple Git-154 (2.39.5) can corrupt short refs (#19515); retire recovery when affected builds are unsupported.
// Preserve current-Git disambiguation when removing that compatibility workaround.
if (shortRef === namespaceName || ![fullRef, namespaceName, naturalName].includes(shortRef)) {
return fullRef
}
// Slash-named locals can collide with remote-tracking refs even without a configured remote.
if (parts[1] === 'heads' && naturalName.includes('/')) {
return fullRef
}
// Natural names beginning with refs/ must not impersonate another namespace.
return shortRef.startsWith('refs/') ? fullRef : shortRef
}