fix(windows): derive nested worktree state from show-cdup

This commit is contained in:
Tom Boucher
2026-05-17 00:36:26 -04:00
parent 3c51e760f8
commit 157f791d45

View File

@@ -98,14 +98,14 @@ function getInitGitState(cwd) {
return resolved;
};
// Most reliable signal: git reports a non-empty prefix only when cwd is
// Most reliable signal: git reports non-empty `--show-cdup` only when cwd is
// below the worktree root. This avoids short/long path alias issues on Windows.
let inNestedSubdir = false;
if (info.inside) {
try {
const prefixResult = execGit(['rev-parse', '--show-prefix'], { cwd, timeout: 5000 });
if (prefixResult.exitCode === 0) {
inNestedSubdir = String(prefixResult.stdout || '').trim().length > 0;
const cdupResult = execGit(['rev-parse', '--show-cdup'], { cwd, timeout: 5000 });
if (cdupResult.exitCode === 0) {
inNestedSubdir = String(cdupResult.stdout || '').trim().length > 0;
} else {
inNestedSubdir = worktreeRoot !== null;
}