Skip to content

fix(server): restore worktree paths on git without worktree list -z - #12263

Open
jaikhuranna wants to merge 1 commit into
pingdotgg:mainfrom
jaikhuranna:fix/git-vcs-driver-newline-worktree-path
Open

jaikhuranna wants to merge 1 commit into
pingdotgg:mainfrom
jaikhuranna:fix/git-vcs-driver-newline-worktree-path

Conversation

@jaikhuranna

@jaikhuranna jaikhuranna commented Sep 17, 2026 •

Copy link
Copy Markdown

Closes #12761

What Changed

git worktree list --porcelain -z fails on git < 2.36 (-z was added in 2.36), and the failure was swallowed by allowNonZeroExit: true — so on older git, every branch silently lost its worktree path in listRefs. This PR retries with the line-delimited porcelain when -z is rejected and parses that form.

  • parseWorktreeBranchPaths now takes the field separator (\0 for -z, \n for plain porcelain) — the record structure is identical.
  • The newline test is now capability-aware: on git ≥ 2.36 it asserts the newline worktree path round-trips; on older git it asserts the ref surfaces with worktreePath: null (the line-delimited form cannot represent newline paths — the truncated path is filtered by the existing stat check).
  • A new mocked-spawner test covers the fallback deterministically on any git version: -z rejected with 129, plain porcelain succeeds, worktree path resolves.
  • The coalescing test now expects 2 worktree scans per snapshot on old git (rejected -z + fallback) instead of 1.

Why

The suite failed on machines with git 2.34 (e.g. Ubuntu 22.04): preserves newline characters in worktree paths when listing refs asserted a worktree path the driver could never produce there. Root cause is the silent -z failure above — the fallback restores worktree paths for all normal cases on older git, and the tests now document the newline limitation honestly instead of assuming modern git.

Stacked on #11729 (this branch is based on it; the diff will shrink to only these changes once that merges).

UI Changes

N/A — no UI changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A — no UI changes
  • N/A — no animation/interaction changes

Verification: full src/vcs suite 95/95 pass on git 2.34.1 (previously 93/94); tsc --noEmit clean for the server package.

Done with GLM (fireworks-ai/glm-flash-latest) via the OpenCode harness in T3 Code.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 17, 2026
@jaikhuranna
jaikhuranna marked this pull request as ready for review September 27, 2026 03:51
@jaikhuranna
jaikhuranna force-pushed the fix/git-vcs-driver-newline-worktree-path branch from 71ec269 to 5838edd Compare September 27, 2026 03:51

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Worktree reuse silently breaks on Git < 2.36 (git worktree list --porcelain -z fails, all refs lose worktreePath)

1 participant