The best way to control Claude Code, Codex and more from any computer or phone
fix(server): git 2.56 broken-gitfile worktrees count as non-repositories again (#33423)
Co-authored-by: Claude Code <noreply@anthropic.com>
Ali-Al1 committed
Nov 11, 2026 at 23:10 UTC
301999c325cebee9f4330ee14ef8c3b083e67a64
4 files changed
+36
-4
apps/server/src/git/GitManager.ts
+2
-1
@@ -86,6 +86,7 @@ import { detachStackFrame } from "./detachStackFrame.ts";
86
import * as ServerSettings from "../serverSettings.ts";
87
import type { GitManagerServiceError } from "@t3tools/contracts";
88
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
89
+import { isNonRepositoryGitStderr } from "../vcs/GitVcsDriverCore.ts";
90
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
91
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
92
import * as SourceControlProviderRegistry from "../sourceControl/SourceControlProviderRegistry.ts";
@@ -198,7 +199,7 @@ type GitActionProgressPayload = StripProgressContext<GitActionProgressEvent>;
199
type GitActionProgressEmitter = (event: GitActionProgressPayload) => Effect.Effect<void, never>;
200
201
function isNotGitRepositoryError(error: GitCommandError): boolean {
201
- return error.message.toLowerCase().includes("not a git repository");
202
+ return isNonRepositoryGitStderr(error.message);
203
}
204
205
interface OpenPrInfo {
apps/server/src/storageCleanup.ts
+2
-1
@@ -47,6 +47,7 @@ import * as Settings from "./serverSettings.ts";
47
import * as TerminalManager from "./terminal/Manager.ts";
48
import { isFilesystemRoot, managedWorktreesDirectories } from "./worktreesDirectory.ts";
49
import * as GitVcsDriver from "./vcs/GitVcsDriver.ts";
50
+import { isNonRepositoryGitStderr } from "./vcs/GitVcsDriverCore.ts";
51
import { removeLinkedWorktree } from "./vcs/worktreeRemoval.ts";
52
import { withWorkspaceLease } from "./workspace/workspaceLease.ts";
53
import * as HostProcess from "@t3tools/shared/HostProcess";
@@ -618,7 +619,7 @@ const make = Effect.gen(function* () {
619
);
620
if (result === null) return null;
621
if (result.exitCode === 0 || result.exitCode === allowedExitCode) return result;
621
- if (result.stderr.toLowerCase().includes("not a git repository")) return null;
622
+ if (isNonRepositoryGitStderr(result.stderr)) return null;
623
return yield* failure(
624
result.stderr.trim().split(/\r?\n/)[0]?.slice(0, 1000) || "command failed",
625
);
apps/server/src/vcs/GitVcsDriverCore.test.ts
+22
@@ -39,6 +39,7 @@ import {
39
import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
40
import * as ServerConfig from "../config.ts";
41
import {
42
+ isNonRepositoryGitStderr,
43
makeGitVcsDriverCore,
44
parseGitCheckoutProgressLine,
45
splitNullSeparatedGitStdoutPaths,
@@ -132,6 +133,27 @@ const makeDriverReleasingLock = (
133
return { driver, failures };
134
});
135
136
+describe("isNonRepositoryGitStderr", () => {
137
+ it.each([
138
+ "fatal: not a git repository (or any of the parent directories): .git",
139
+ "fatal: not a git repository: /missing-git-directory",
140
+ // Git 2.56+ wording for a `.git` gitfile that points at a missing directory.
141
+ "fatal: gitfile does not point to a valid repository: /tmp/worktrees/feature/.git",
142
+ "FATAL: GITFILE DOES NOT POINT TO A VALID REPOSITORY: /tmp/x/.git",
143
+ ])("classifies %j as a non-repository", (stderr) => {
144
+ assert.isTrue(isNonRepositoryGitStderr(stderr));
145
+ });
146
+
147
+ it.each([
148
+ "",
149
+ "fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.",
150
+ "fatal: Unable to create '/repo/.git/index.lock': File exists.",
151
+ "fatal: invalid gitfile format: /repo/.git",
152
+ ])("does not classify %j as a non-repository", (stderr) => {
153
+ assert.isFalse(isNonRepositoryGitStderr(stderr));
154
+ });
155
+});
156
+
157
it.effect("runs background Git in its own lane so user commands never queue behind it", () =>
158
Effect.gen(function* () {
159
const gate = yield* Deferred.make<void>();
apps/server/src/vcs/GitVcsDriverCore.ts
+10
-2
@@ -568,8 +568,16 @@ function isMissingGitCwdError(error: GitCommandError): boolean {
568
);
569
}
570
571
-function isNonRepositoryGitStderr(stderr: string): boolean {
572
- return stderr.toLowerCase().includes("not a git repository");
571
+// Git 2.56+ reports a `.git` gitfile pointing nowhere as "gitfile does not point to a valid
572
+// repository"; older releases said "not a git repository". Both mean the cwd is not a repository.
573
+const NON_REPOSITORY_STDERR_PHRASES = [
574
+ "not a git repository",
575
+ "gitfile does not point to a valid repository",
576
+] as const;
577
+
578
+export function isNonRepositoryGitStderr(stderr: string): boolean {
579
+ const normalized = stderr.toLowerCase();
580
+ return NON_REPOSITORY_STDERR_PHRASES.some((phrase) => normalized.includes(phrase));
581
}
582
function isUnbornHeadStderr(stderr: string): boolean {
583
const normalized = stderr.toLowerCase();