Repository navigation
List worktrees with -z and decode quoted lock/prunable reasons [patch] - #207
Merged
Merged
Conversation
worktree list --porcelain prints paths raw, so a path containing a newline was split across two lines and reported as a different directory. On git 2.36 and later the builder now asks for -z, probing the version the way Fetch does, and the parser reads NUL-terminated fields with raw values. Below 2.36 the newline form remains, and its C-quoted locked/prunable reasons are decoded with GitPatchParser.UnquotePath instead of being returned still quoted. Fixes #141 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015EHSar1iXDsM19Xk1rHpKp
On macOS the temp root is /var/folders/..., which git reports resolved as /private/var/folders/..., so a full-path comparison failed on macOS only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015EHSar1iXDsM19Xk1rHpKp
Windows forbids a newline in a path, so AbsoluteDirectoryPath rejects the fixture there; the same guard the colon-name integration test uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015EHSar1iXDsM19Xk1rHpKp
|
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.



Fixes #141
Before:
Worktrees()parsedgit worktree list --porcelainline by line. Git prints theworktreepath raw, so a worktree at…/odd<LF>dir/wtwas reported at…/oddwith no error.needs "care"<LF>second linecame back as"needs \"care\"\nsecond line", still quoted. Prunable reasons had the same problem.After:
worktree list --porcelain -z. Every field is NUL-terminated and printed raw, so paths and reasons come back as git stores them.-zdoesn't exist and the newline form stays. Its C-quotedlocked/prunablereasons are now decoded with the existingGitPatchParser.UnquotePath. A newline in a path can't be represented in that form, and the builder remarks say so.How:
GitWorktreeListBuilderprobes the installed git version throughTryExecuteAsync, the same wayGitFetchBuilderdoes. A failed probe falls back to the newline form.BuildArguments()on its own shows the-zvector.GitWorktreeParser.Parse(output, nulTerminated)splits on NUL under-zand doesn't trim\rthere. An empty field closes a record.Tests (git 2.43 on Linux):
-z, and a raw reason under-z.-zis emitted on 2.36 and its output is parsed; it is not emitted on 2.35, where the output is decoded.Worktrees(). On Windows the path is plain and only the reason is awkward.🤖 Generated with Claude Code
https://claude.ai/code/session_015EHSar1iXDsM19Xk1rHpKp
Generated by Claude Code