fix(desktop): honor selected local project branch - #5974
Conversation
Co-authored-by: wlg949 <xt349100921@protonmail.com> Signed-off-by: wlg949 <xt349100921@protonmail.com>
Co-authored-by: wlg949 <xt349100921@protonmail.com> Signed-off-by: wlg949 <xt349100921@protonmail.com>
themiguelamador
left a comment
There was a problem hiding this comment.
I found one selected-ref correctness issue: the new reader used line-delimited git ls-tree output. Git C-quotes valid filenames containing tabs/newlines (and, depending on configuration, non-ASCII bytes), so Local could display the quoted spelling, fail to associate last-commit metadata, and omit the preview because that spelling is not the real tree path. The active-worktree path already avoids this class with NUL delimiters.
I fixed it in Complear/buzz commit 222892e30 (review/pr-5974-fix) by parsing git ls-tree -z as bytes, disabling unnecessary Unicode path quoting in the history query, and resolving the exceptional quoted history paths exactly. The regression now also removes the local branch and proves the origin/* fallback preserves a tab-containing path, its preview, and latest commit metadata.
Verification: full Tauri workspace suite (2,443 passed, 15 expected OS-keychain ignores), focused project Git tests, strict Tauri-library Clippy, Rust formatting, and git diff --check.
Summary
origin/*ref without checking it out or mutating the working directoryHEADmainis selectedRoot cause
The frontend already passed the selected branch into
get_project_local_repo_snapshot, butsnapshot_from_worktreeused unqualifiedHEAD,git log, andgit ls-files. The selector therefore changed query state without changing the commit or files rendered by Local.Implementation
For the active branch, the existing worktree snapshot remains unchanged so local edits and untracked files stay visible. For any other selected branch, the backend resolves
refs/heads/<branch>first andrefs/remotes/origin/<branch>second, then reads commits, contributors, tree entries, and UTF-8 previews directly from that ref. Blob previews use a singlegit cat-file --batchprocess rather than one subprocess per file.The selected-ref path only runs read-only Git commands (
rev-parse,log,ls-tree, andcat-file); it never checks out a branch or mutates the working tree, index, orHEAD.Validation
Validated implementation commit:
31f6ce27ea84d2884bc9b627ce3e4cedd7c82c39.git diff --checkpassedproject_gitfile appears in the diagnostics, and Linux Clippy passedBuzz origin
buzz://message?channel=953cc31b-96dd-4b1a-9658-8872dfec35e5&id=342192eb4bffd9cfebb996e71d4341ec0a5cf4fd6b939f42c75d985ca20446c1