fix(server): status polling no longer locks the git index (#14718)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
ahalekellyandClaude Opus 5.5 authored and GitHub committed 2026-10-06 04:12:18 +00:00
1 parent 570b72d839
commit 447046b589
1 file changed
+9 -4
+9 -4
View File
@@ -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,