From 2782fd05fbde81c0f6e6487c412637218e78507b Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Sun, 17 May 2026 01:14:57 -0400 Subject: [PATCH] fix(windows): derive nested-worktree state from normalized paths --- get-shit-done/bin/lib/init.cjs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/get-shit-done/bin/lib/init.cjs b/get-shit-done/bin/lib/init.cjs index d06ffd547..20e58f54d 100644 --- a/get-shit-done/bin/lib/init.cjs +++ b/get-shit-done/bin/lib/init.cjs @@ -98,24 +98,8 @@ function getInitGitState(cwd) { return resolved; }; - // 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 cdupResult = execGit(['rev-parse', '--show-cdup'], { cwd, timeout: 5000 }); - if (cdupResult.exitCode === 0) { - const cdup = String(cdupResult.stdout || '').trim().replace(/\\/g, '/'); - inNestedSubdir = cdup.length > 0 && cdup !== '.' && cdup !== './'; - } else { - inNestedSubdir = worktreeRoot !== null; - } - } catch { - inNestedSubdir = worktreeRoot !== null; - } - } - - if (inNestedSubdir) { const rootNorm = normalizeForCompare(worktreeRoot); const cwdNorm = normalizeForCompare(cwd); if (rootNorm && cwdNorm) { @@ -130,6 +114,19 @@ function getInitGitState(cwd) { !relNorm.startsWith('..') && !path.isAbsolute(relNorm); } + } else { + // Fallback only when root/cwd normalization fails. + try { + const cdupResult = execGit(['rev-parse', '--show-cdup'], { cwd, timeout: 5000 }); + if (cdupResult.exitCode === 0) { + const cdup = String(cdupResult.stdout || '').trim().replace(/\\/g, '/'); + inNestedSubdir = cdup.length > 0 && cdup !== '.' && cdup !== './'; + } else { + inNestedSubdir = worktreeRoot !== null; + } + } catch { + inNestedSubdir = worktreeRoot !== null; + } } }