Skip to content

Commit 811e03e

Browse files
fix(server): keep repository identity for roots whose name ends in a space
git rev-parse output was trimmed, dropping a trailing space that is part of the repository root's folder name, so the follow-up git -C call ran against a missing folder and the identity resolved to null. Strip only git's line terminator, for both the work-tree and bare-repository paths. Fixes #35747 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent e9dac3d commit 811e03e

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎apps/server/src/project/RepositoryIdentityResolver.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ const resolveRepositoryIdentityCacheKey = Effect.fn("RepositoryIdentityResolver.
180180
return null;
181181
}
182182
if (topLevelResult.value.code === 0) {
183-
const rootPath = topLevelResult.value.stdout.trim();
183+
// Paths may end in spaces, so strip only git's line terminator.
184+
const rootPath = topLevelResult.value.stdout.replace(/\r?\n$/, "");
184185
return rootPath.length > 0
185186
? new RepositoryIdentityCacheKey({ rootPath, isBare: false })
186187
: null;
@@ -224,9 +225,7 @@ const resolveRepositoryIdentityCacheKey = Effect.fn("RepositoryIdentityResolver.
224225
if (bareResult._tag === "None" || bareResult.value.timedOut) return null;
225226
if (bareResult.value.code !== 0) continue;
226227

227-
const [isBare, rootPath = ""] = bareResult.value.stdout
228-
.split("\n")
229-
.map((line) => line.trim());
228+
const [isBare, rootPath = ""] = bareResult.value.stdout.split(/\r?\n/);
230229
// A checkout's .git directory contains remotes but is not a project root.
231230
return isBare === "true" && rootPath.length > 0
232231
? new RepositoryIdentityCacheKey({ rootPath, isBare: true })

0 commit comments

Comments
 (0)