Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/server/src/vcs/GitVcsDriverCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4222,6 +4222,11 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
NodeFS.existsSync(path.join(status.workingTree.rootPath!, "nested", "new.txt")),
true,
);
// Git prints index and object paths relative to its physical cwd, not this alias.
const aliasCwd = path.join(yield* makeTmpDir(), "alias");
NodeFS.symlinkSync(nestedCwd, aliasCwd, "junction");
const prepared = yield* driver.prepareCommitContext(aliasCwd, ["nested/new.txt"]);
assert.include(prepared?.stagedSummary ?? "", "nested/new.txt");
yield* driver.commit(nestedCwd, "Commit nested selection", "", {
stage: { filePaths: ["nested/new.txt", "nested/tracked.txt"] },
});
Expand Down
6 changes: 4 additions & 2 deletions apps/server/src/vcs/GitVcsDriverCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2633,7 +2633,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
cwd,
["rev-parse", "--git-path", "index", "--git-path", "objects"],
)).split("\n");
const indexPath = path.resolve(cwd, indexValue.trim());
// Git prints these relative to its physical cwd, so resolve them past a symlinked cwd.
const physicalCwd = yield* fileSystem.realPath(cwd).pipe(Effect.orElseSucceed(() => cwd));
const indexPath = path.resolve(physicalCwd, indexValue.trim());
const directory = yield* fileSystem.makeTempDirectoryScoped({
prefix: "t3code-commit-index-",
});
Expand All @@ -2651,7 +2653,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
const quoted = (entry: string) =>
entry.startsWith('"') ? entry : `"${entry.replace(/[\\"]/g, "\\$&")}"`;
const alternates = [
path.resolve(cwd, objectsValue.trim()),
path.resolve(physicalCwd, objectsValue.trim()),
...objectDirectories
.split("\n")
.flatMap((line) =>
Expand Down
Loading