Repository navigation
fix(server): restore worktree paths on git without worktree list -z - #12263
Draft
jaikhuranna wants to merge 1 commit into
Draft
jaikhuranna wants to merge 1 commit into
jaikhuranna wants to merge 1 commit into
Conversation
2 tasks done
jaikhuranna
marked this pull request as ready for review
September 27, 2026 03:51
jaikhuranna
force-pushed
the
fix/git-vcs-driver-newline-worktree-path
branch
from
September 27, 2026 03:51
71ec269 to
5838edd
Compare
| }; | ||
|
|
||
| for (const field of stdout.split("\0")) { | ||
| for (const field of stdout.split(fieldSeparator)) { |
Contributor
There was a problem hiding this comment.
🟡 Medium vcs/GitVcsDriverCore.ts:296
The "\n" fallback can report /worktrees/feature as the worktree path for a branch whose actual path is /worktrees/feature\nnotes. Splitting on newlines turns the path prefix into currentPath, and the later stat check does not catch this when that prefix exists. Use the -z output for paths that may contain newlines, or reject/avoid parsing such entries in the fallback.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/vcs/GitVcsDriverCore.ts around line 296:
The `"\n"` fallback can report `/worktrees/feature` as the worktree path for a branch whose actual path is `/worktrees/feature\nnotes`. Splitting on newlines turns the path prefix into `currentPath`, and the later `stat` check does not catch this when that prefix exists. Use the `-z` output for paths that may contain newlines, or reject/avoid parsing such entries in the fallback.
jaikhuranna
marked this pull request as draft
October 1, 2026 14:36
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #12761
What Changed
git worktree list --porcelain -zfails on git < 2.36 (-zwas added in 2.36), and the failure was swallowed byallowNonZeroExit: true— so on older git, every branch silently lost its worktree path inlistRefs. This PR retries with the line-delimited porcelain when-zis rejected and parses that form.parseWorktreeBranchPathsnow takes the field separator (\0for-z,\nfor plain porcelain) — the record structure is identical.worktreePath: null(the line-delimited form cannot represent newline paths — the truncated path is filtered by the existingstatcheck).-zrejected with 129, plain porcelain succeeds, worktree path resolves.-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 refsasserted a worktree path the driver could never produce there. Root cause is the silent-zfailure 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
Verification: full
src/vcssuite 95/95 pass on git 2.34.1 (previously 93/94);tsc --noEmitclean for the server package.Done with GLM (fireworks-ai/glm-flash-latest) via the OpenCode harness in T3 Code.