From 8d828b139d374dbae082122350606f2926e9f96a Mon Sep 17 00:00:00 2001 From: Antisophy <293439221+Antisophy@users.noreply.github.com> Date: Sun, 14 Jun 2026 21:16:55 -0700 Subject: [PATCH] fix(worktree): treat non-git project paths as having no archive ref getArchiveRefState threw on any git exit status other than 0 or 1, so a project path that isn't a git work tree (e.g. an "unrestricted" workspace rooted at $HOME) made git rev-parse exit 128 and aborted the whole archive transition. Unarchiving such a task failed with "not a git repository". Short-circuit to Missing when the path isn't inside a work tree, before the strict status check, restoring the pre-8225c1e tolerance while still throwing on genuine git failures inside a real repo. --- source/cydo/worktree.d | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/cydo/worktree.d b/source/cydo/worktree.d index 4574c9d..5b9b2b2 100644 --- a/source/cydo/worktree.d +++ b/source/cydo/worktree.d @@ -17,6 +17,14 @@ private enum ArchiveRefState private ArchiveRefState getArchiveRefState(string projectPath, int tid) { + // a non-git projectPath (e.g. an "unrestricted" workspace rooted at a plain + // directory like $HOME) can't hold an archive ref at all; rev-parse would + // bail with "not a git repository" (exit 128), so resolve to Missing before + // the strict status check below treats non-0/1 exits as genuine git failures + auto insideWorkTree = execute(["git", "-C", projectPath, "rev-parse", "--is-inside-work-tree"]); + if (insideWorkTree.status != 0) + return ArchiveRefState.Missing; + auto refName = format!"refs/cydo/worktree-archive/%d"(tid); auto cmd = ["git", "-C", projectPath, "rev-parse", "--verify", "--quiet", refName]; auto result = execute(cmd);