The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 16:30 UTC
fix(server): handle files named HEAD in git status (#6397)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com>
Simone committed
Aug 14, 2026 at 23:56 UTC
f0719072a1c6435b5a91243afc57bc8bf1f3e2b6
2 files changed
+26
-4
apps/server/src/vcs/GitVcsDriverCore.test.ts
+21
@@ -950,6 +950,27 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {
950
}),
951
);
952
953
+ it.effect("reports changes to a file named HEAD", () =>
954
+ Effect.gen(function* () {
955
+ const cwd = yield* makeTmpDir();
956
+ yield* initRepoWithCommit(cwd);
957
+ yield* writeTextFile(cwd, "HEAD", "first line\n");
958
+ yield* git(cwd, ["add", "HEAD"]);
959
+ yield* git(cwd, ["commit", "-m", "add HEAD file"]);
960
+ yield* writeTextFile(cwd, "HEAD", "first line\nsecond line\n");
961
+
962
+ const status = yield* (yield* GitVcsDriver.GitVcsDriver).statusDetails(cwd);
963
+
964
+ assert.equal(status.isRepo, true);
965
+ assert.equal(status.hasWorkingTreeChanges, true);
966
+ assert.deepInclude(status.workingTree.files, {
967
+ path: "HEAD",
968
+ insertions: 1,
969
+ deletions: 0,
970
+ });
971
+ }),
972
+ );
973
+
974
it.effect("reports default-branch delta separately from upstream delta", () =>
975
Effect.gen(function* () {
976
const cwd = yield* makeTmpDir();
apps/server/src/vcs/GitVcsDriverCore.ts
+5
-4
@@ -420,9 +420,10 @@ function isNonRepositoryGitStderr(stderr: string): boolean {
420
return stderr.toLowerCase().includes("not a git repository");
421
}
422
function isUnbornHeadStderr(stderr: string): boolean {
423
+ const normalized = stderr.toLowerCase();
424
return (
424
- stderr.toLowerCase().includes("unknown revision") &&
425
- stderr.toLowerCase().includes("path not in the working tree")
425
+ normalized.includes("bad revision 'head'") ||
426
+ (normalized.includes("unknown revision") && normalized.includes("path not in the working tree"))
427
);
428
}
429
@@ -1600,7 +1601,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
1601
executeGitWithStableDiagnostics(
1602
"GitVcsDriver.statusDetails.numstat",
1603
cwd,
1603
- ["diff", "HEAD", "--numstat"],
1604
+ ["diff", "HEAD", "--numstat", "--"],
1605
{ allowNonZeroExit: true },
1606
).pipe(
1607
Effect.flatMap((result) => {
@@ -1642,7 +1643,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
1643
...gitCommandContext({
1644
operation: "GitVcsDriver.statusDetails.numstat",
1645
cwd,
1645
- args: ["diff", "HEAD", "--numstat"],
1646
+ args: ["diff", "HEAD", "--numstat", "--"],
1647
}),
1648
detail: "git diff HEAD --numstat failed.",
1649
exitCode: result.exitCode,