@devries-cameron20 / t3code-1 / commits / 1cba2f64d3
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Harden workspace git indexing against repo-configured fsmonitor execution (#1873)

Julius Marminge committed Apr 10, 2026 at 01:07 UTC 1cba2f64d39073bb77faac7234e88f52aa395643
2 files changed +57 -5
apps/server/src/git/Layers/GitCore.test.ts
+33 -1
@@ -219,7 +219,10 @@ it.layer(TestLayer)("git integration", (it) => {
219
220 const seenChunks: string[][] = [];
221 const core = yield* makeIsolatedGitCore((input) => {
222 - if (input.args.join(" ") !== "check-ignore --no-index -z --stdin") {
222 + if (
223 + input.args.join(" ") !==
224 + "-c core.fsmonitor=false -c core.untrackedCache=false check-ignore --no-index -z --stdin"
225 + ) {
226 return Effect.fail(
227 new GitCommandError({
228 operation: input.operation,
@@ -252,6 +255,35 @@ it.layer(TestLayer)("git integration", (it) => {
255 expect(result).toEqual(expectedPaths);
256 }),
257 );
258 +
259 + it.effect("listWorkspaceFiles disables fsmonitor and untracked cache helpers", () =>
260 + Effect.gen(function* () {
261 + const core = yield* makeIsolatedGitCore((input) => {
262 + expect(input.args).toEqual([
263 + "-c",
264 + "core.fsmonitor=false",
265 + "-c",
266 + "core.untrackedCache=false",
267 + "ls-files",
268 + "--cached",
269 + "--others",
270 + "--exclude-standard",
271 + "-z",
272 + ]);
273 + return Effect.succeed({
274 + code: 0,
275 + stdout: "src/index.ts\0README.md\0",
276 + stderr: "",
277 + stdoutTruncated: false,
278 + stderrTruncated: false,
279 + });
280 + });
281 +
282 + const result = yield* core.listWorkspaceFiles("/virtual/repo");
283 + expect(result.paths).toEqual(["src/index.ts", "README.md"]);
284 + expect(result.truncated).toBe(false);
285 + }),
286 + );
287 });
288
289 // ── listGitBranches ──
apps/server/src/git/Layers/GitCore.ts
+24 -4
@@ -47,6 +47,12 @@ const RANGE_DIFF_SUMMARY_MAX_OUTPUT_BYTES = 19_000;
47 const RANGE_DIFF_PATCH_MAX_OUTPUT_BYTES = 59_000;
48 const WORKSPACE_FILES_MAX_OUTPUT_BYTES = 16 * 1024 * 1024;
49 const GIT_CHECK_IGNORE_MAX_STDIN_BYTES = 256 * 1024;
50 +const WORKSPACE_GIT_HARDENED_CONFIG_ARGS = [
51 + "-c",
52 + "core.fsmonitor=false",
53 + "-c",
54 + "core.untrackedCache=false",
55 +] as const;
56 const STATUS_UPSTREAM_REFRESH_INTERVAL = Duration.seconds(15);
57 const STATUS_UPSTREAM_REFRESH_TIMEOUT = Duration.seconds(5);
58 const STATUS_UPSTREAM_REFRESH_FAILURE_COOLDOWN = Duration.seconds(5);
@@ -1619,7 +1625,14 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
1625 executeGit(
1626 "GitCore.listWorkspaceFiles",
1627 cwd,
1622 - ["ls-files", "--cached", "--others", "--exclude-standard", "-z"],
1628 + [
1629 + ...WORKSPACE_GIT_HARDENED_CONFIG_ARGS,
1630 + "ls-files",
1631 + "--cached",
1632 + "--others",
1633 + "--exclude-standard",
1634 + "-z",
1635 + ],
1636 {
1637 allowNonZeroExit: true,
1638 timeoutMs: 20_000,
@@ -1637,7 +1650,14 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
1650 createGitCommandError(
1651 "GitCore.listWorkspaceFiles",
1652 cwd,
1640 - ["ls-files", "--cached", "--others", "--exclude-standard", "-z"],
1653 + [
1654 + ...WORKSPACE_GIT_HARDENED_CONFIG_ARGS,
1655 + "ls-files",
1656 + "--cached",
1657 + "--others",
1658 + "--exclude-standard",
1659 + "-z",
1660 + ],
1661 result.stderr.trim().length > 0 ? result.stderr.trim() : "git ls-files failed",
1662 ),
1663 ),
@@ -1657,7 +1677,7 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
1677 const result = yield* executeGit(
1678 "GitCore.filterIgnoredPaths",
1679 cwd,
1660 - ["check-ignore", "--no-index", "-z", "--stdin"],
1680 + [...WORKSPACE_GIT_HARDENED_CONFIG_ARGS, "check-ignore", "--no-index", "-z", "--stdin"],
1681 {
1682 stdin: `${chunk.join("\0")}\0`,
1683 allowNonZeroExit: true,
@@ -1671,7 +1691,7 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
1691 return yield* createGitCommandError(
1692 "GitCore.filterIgnoredPaths",
1693 cwd,
1674 - ["check-ignore", "--no-index", "-z", "--stdin"],
1694 + [...WORKSPACE_GIT_HARDENED_CONFIG_ARGS, "check-ignore", "--no-index", "-z", "--stdin"],
1695 result.stderr.trim().length > 0 ? result.stderr.trim() : "git check-ignore failed",
1696 );
1697 }