Skip to content

Commit 4a8d0f2

Browse files
fix(server): branches whose names start with a parenthesis are no longer reported as detached
Git status --porcelain=v2 prints the literal (detached) for a detached HEAD, so only that value means no branch. Storage cleanup's branch check mirrored the old prefix test and now compares the checked-out branch as is. Fixes #35753 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1644982 commit 4a8d0f2

3 files changed

Lines changed: 3 additions & 8 deletions

File tree

‎apps/server/src/storageCleanup.test.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2618,17 +2618,12 @@ describe("storage cleanup reports and local file policies", () => {
26182618
it.live("compares the checked-out branch without a full status", () =>
26192619
runCleanupTest(
26202620
Effect.gen(function* () {
2621-
const { service, fs, repo, worktree, command, setThreads, fullStatusCalls } =
2622-
yield* cleanupFixture();
2621+
const { service, fs, repo, worktree, command, fullStatusCalls } = yield* cleanupFixture();
26232622
const changed = { outcome: "kept", reason: "Repository or branch changed" };
26242623
yield* command(worktree, ["checkout", "--detach"]);
26252624
expect((yield* service.runNow).entries[0]).toMatchObject(changed);
26262625
yield* command(worktree, ["switch", "--orphan", "other"]);
26272626
expect((yield* service.runNow).entries[0]).toMatchObject(changed);
2628-
yield* command(worktree, ["switch", "-c", "(feature)", "feature"]);
2629-
setThreads([shell({ branch: "(feature)", worktreePath: worktree })]);
2630-
expect((yield* service.runNow).entries[0]).toMatchObject(changed);
2631-
setThreads([shell({ branch: "feature", worktreePath: worktree })]);
26322627
yield* command(worktree, ["tag", "feature", "feature"]);
26332628
// Newer Git refuses to create a tag named HEAD, but still reads one.
26342629
yield* command(worktree, ["update-ref", "refs/tags/HEAD", "refs/heads/feature"]);

‎apps/server/src/storageCleanup.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ const make = Effect.gen(function* () {
706706
if (head === null) return true;
707707
const ref = head.exitCode === 0 ? head.stdout.trim() : "";
708708
const name = ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length).trim() : null;
709-
return (name?.startsWith("(") ? null : name) !== branch;
709+
return name !== branch;
710710
});
711711

712712
// Git status and non-forced worktree removal both skip assume-unchanged and skip-worktree files.

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2325,7 +2325,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
23252325
const line = statusRecords[index]!;
23262326
if (line.startsWith("# branch.head ")) {
23272327
const value = line.slice("# branch.head ".length).trim();
2328-
refName = value.startsWith("(") ? null : value;
2328+
refName = value === "(detached)" ? null : value;
23292329
continue;
23302330
}
23312331
if (line.startsWith("# branch.upstream ")) {

0 commit comments

Comments
 (0)