From 447046b589140a50a4a782453133da83ff77e85e Mon Sep 17 00:00:00 2001 From: ahalekelly <7078138+ahalekelly@users.noreply.github.com> Date: Mon, 5 Oct 2026 21:12:18 -0700 Subject: [PATCH] fix(server): status polling no longer locks the git index (#14718) Co-authored-by: Claude Opus 5.5 (1M context) --- apps/server/src/vcs/GitVcsDriverCore.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.ts index 9ec0d4e7753a346f5df99c51c3762264365f1cd3..92f7478fa34bd2983f7f777ea0ae73e6a0a1d8ea 100644 --- a/apps/server/src/vcs/GitVcsDriverCore.ts +++ b/apps/server/src/vcs/GitVcsDriverCore.ts @@ -931,6 +931,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* cwd: commandInput.cwd, env: { ...process.env, + // Status polling runs beside the user's own git commands; without this, + // `git status` takes index.lock to save its refreshed index. + GIT_OPTIONAL_LOCKS: "0", ...input.env, ...trace2Monitor.env, }, @@ -1875,10 +1878,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* const statusCacheKey = repositoryPaths?.gitCommonDir; const [numstatStdout, defaultBranch, hasPrimaryRemote] = yield* Effect.all( [ + // Plumbing, because porcelain `git diff` rewrites the index even with + // GIT_OPTIONAL_LOCKS=0. -M keeps porcelain's rename detection. executeGitWithStableDiagnostics( "GitVcsDriver.statusDetails.numstat", cwd, - ["diff", "HEAD", "--numstat", "--"], + ["diff-index", "-M", "--numstat", "HEAD", "--"], { allowNonZeroExit: true }, ).pipe( Effect.flatMap((result) => { @@ -1887,7 +1892,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* return Effect.map( Effect.all([ runGitStdout("GitVcsDriver.statusDetails.numstat.unborn", cwd, [ - "diff", + "diff-files", "--numstat", ]), runGitStdout("GitVcsDriver.statusDetails.numstat.unborn.staged", cwd, [ @@ -1920,9 +1925,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* ...gitCommandContext({ operation: "GitVcsDriver.statusDetails.numstat", cwd, - args: ["diff", "HEAD", "--numstat", "--"], + args: ["diff-index", "-M", "--numstat", "HEAD", "--"], }), - detail: "git diff HEAD --numstat failed.", + detail: "git diff-index HEAD --numstat failed.", exitCode: result.exitCode, stdoutLength: result.stdout.length, stderrLength: result.stderr.length, -- 2.54.0