@devries-cameron20 / t3code Mirror · read-only / commits / 49b858b807
Fork 0

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 21, 19:45 UTC

fix(git): selected-file commits work through symlinked subdirectories (#35278)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

kirat02 committed Nov 12, 2026 at 22:34 UTC 49b858b807faf994569bd435c942abee478adcaf
2 files changed +38 -22
apps/server/src/vcs/GitVcsDriverCore.test.ts
+34 -20
@@ -6341,28 +6341,42 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
6341 }),
6342 );
6343
6344 - it.effect("prepares selected files without staging and commits only those files", () =>
6345 - Effect.gen(function* () {
6346 - const cwd = yield* makeTmpDir();
6347 - yield* initRepoWithCommit(cwd);
6348 - const driver = yield* GitVcsDriver.GitVcsDriver;
6349 -
6350 - yield* writeTextFile(cwd, "a.txt", "a\n");
6351 - yield* writeTextFile(cwd, "b.txt", "b\n");
6352 -
6353 - const context = yield* driver.prepareCommitContext(cwd, ["a.txt"]);
6354 - assert.include(context?.stagedSummary ?? "", "a.txt");
6355 - assert.notInclude(context?.stagedSummary ?? "", "b.txt");
6356 - assert.equal(yield* git(cwd, ["diff", "--cached", "--name-only"]), "");
6344 + it.effect.each(["root", "aliased-nested"] as const)(
6345 + "prepares selected files without staging and commits only those files from %s",
6346 + (location) =>
6347 + Effect.gen(function* () {
6348 + const sandbox = yield* makeTmpDir();
6349 + const path = yield* Path.Path;
6350 + const fileSystem = yield* FileSystem.FileSystem;
6351 + const repository = path.join(sandbox, "repo");
6352 + const nested = path.join(repository, "sub", "dir");
6353 + yield* fileSystem.makeDirectory(nested, { recursive: true });
6354 + yield* initRepoWithCommit(repository);
6355 + const cwd = location === "aliased-nested" ? path.join(sandbox, "link") : repository;
6356 + if (location === "aliased-nested") NodeFS.symlinkSync(nested, cwd, "junction");
6357 + const driver = yield* GitVcsDriver.GitVcsDriver;
6358 + const selected = "sub/dir/a.txt";
6359 + yield* writeTextFile(repository, selected, "a\n");
6360 + yield* writeTextFile(repository, "b.txt", "b\n");
6361
6358 - const commit = yield* driver.commit(cwd, "Add a", "", { stage: { filePaths: ["a.txt"] } });
6359 - assert.match(commit.commitSha, /^[a-f0-9]{40}$/);
6360 - assert.equal(yield* git(cwd, ["log", "-1", "--pretty=%s"]), "Add a");
6362 + const context = yield* driver.prepareCommitContext(cwd, [selected]);
6363 + assert.include(context?.stagedSummary ?? "", "a.txt");
6364 + assert.notInclude(context?.stagedSummary ?? "", "b.txt");
6365 + assert.equal(yield* git(repository, ["diff", "--cached", "--name-only"]), "");
6366
6362 - const status = yield* git(cwd, ["status", "--porcelain"]);
6363 - assert.include(status, "?? b.txt");
6364 - assert.notInclude(status, "a.txt");
6365 - }),
6367 + const commit = yield* driver.commit(cwd, "Add a", "", {
6368 + stage: { filePaths: [selected] },
6369 + });
6370 + assert.match(commit.commitSha, /^[a-f0-9]{40}$/);
6371 + assert.equal(yield* git(repository, ["log", "-1", "--pretty=%s"]), "Add a");
6372 + assert.equal(
6373 + yield* git(repository, ["diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD"]),
6374 + selected,
6375 + );
6376 + const status = yield* git(repository, ["status", "--porcelain"]);
6377 + assert.include(status, "?? b.txt");
6378 + assert.notInclude(status, "a.txt");
6379 + }),
6380 );
6381
6382 it.effect("stops a selected-file commit when another process holds the index lock", () =>
apps/server/src/vcs/GitVcsDriverCore.ts
+4 -2
@@ -2633,7 +2633,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2633 cwd,
2634 ["rev-parse", "--git-path", "index", "--git-path", "objects"],
2635 )).split("\n");
2636 - const indexPath = path.resolve(cwd, indexValue.trim());
2636 + // Git's relative paths use the physical cwd, even when the project uses a symlink.
2637 + const physicalCwd = yield* fileSystem.realPath(cwd);
2638 + const indexPath = path.resolve(physicalCwd, indexValue.trim());
2639 const directory = yield* fileSystem.makeTempDirectoryScoped({
2640 prefix: "t3code-commit-index-",
2641 });
@@ -2651,7 +2653,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2653 const quoted = (entry: string) =>
2654 entry.startsWith('"') ? entry : `"${entry.replace(/[\\"]/g, "\\$&")}"`;
2655 const alternates = [
2654 - path.resolve(cwd, objectsValue.trim()),
2656 + path.resolve(physicalCwd, objectsValue.trim()),
2657 ...objectDirectories
2658 .split("\n")
2659 .flatMap((line) =>