Add branch file transfers, merge previews and branch cleanup tools #67
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
state: Done
state: New
state: To Do
type: Bug
type: Feature
type: Task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Christoph/Gitty!67
Loading…
Reference in a new issue
No description provided.
Delete branch "codex/branch-workflows"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This change adds branch-focused workflows and supporting plumbing for selecting and transferring files or parts of files between branches, previewing merges, and cleaning up merged or stale branch refs.
In short: the repository gains new Tauri commands and client-visible flows to take or merge individual files/lines from another branch, preview the effects of merging a branch into the current branch, undo the last file transfer, and review/delete eligible local (and optionally stale remote-tracking) refs.
Key outcomes (evidence from diffs):
File/line selection and restore
src-tauri/src/git/branch_files.rs:get_branch_file_changes,take_branch_files,get_branch_file_patch, andapply_branch_file_patchimplement selecting files, computing/returning patches for selected lines/hunks, and applying those patches with checks. They validate repository state (expected HEAD and branch), refuse submodules and directory/file transitions, and avoid traversing worktree symlinks before modifying files.README.mdunder "Branch workflows": you can right-click another branch and "Take files …", select files or individual lines/hunks, and restore or stage the selected content. Results are left unstaged; index and branch tip are preserved.scripts/line-patch.test.mjsthat compiles a selection helper from the Svelte component source and exercises selection of lines beginning with---and+++to ensure those lines can be recognized and selected.Three-way file merge workbench for selected file merges
src-tauri/src/git/branch_merge.rsexposes merge-related types and functions to produce a common-ancestor three-way merge for a file (base/ours/theirs), return content and executable bits, and drive a conflict workbench-style resolution. The README notes that the same workbench as normal conflict resolution is used for per-file merges.Previewing branch merges
merge_previewtosrc-tauri/src/git.rs.Branch cleanup assistant
src-tauri/src/git/branch_cleanup.rsimplementspreview_branch_cleanupandapply_branch_cleanup. The preview collects branch candidates (local heads) and optional remote-tracking references, classifies them (merged/unmerged/protected/worktree/base), and returns a plan.apply_branch_cleanupre-checks the plan, verifies selected refs and commit IDs, prevents deleting refs in-use by worktrees, and performs atomic ref deletions viagit update-ref --stdin. The code explicitly skips server-side deletes and warns/skips remotes with custom fetch mappings.Persistent per-worktree undo for file transfers
with_transfer_undo(...)(module exposed insrc-tauri/src/git.rs), preserving the previous contents so the UI can restore the last transfer for the worktree. The README documents the conditions under which the undo is refused (it will not overwrite newer edits, staging changes, or a changed branch/HEAD).Safety checks and constraints
branch_files.rs,branch_merge.rsandbranch_cleanup.rs.Files changed or added (high level):
src-tauri/src/git/branch_files.rs,branch_merge.rs,branch_cleanup.rs,transfer_undoandmerge_previeware wired intosrc-tauri/src/git.rs.README.mdandCHANGELOG.mdupdated to describe the new branch workflows and features.scripts/line-patch.test.mjsadded to exercise the patch parser/selection logic.Testing
scripts/line-patch.test.mjsis a new unit-style test that compiles and exercises the component's patch parsing/selecting logic against a real Git repo.Recommended checks for reviewers
cargo build(or the project's normal Tauri build step) to ensure the new Rust modules compile and are wired correctly.node --test scripts/line-patch.test.mjs(or your project's test command) to exercise the patch selection logic that recognizes---/+++lines.Compatibility and migration notes
README.md.refs/heads/*:refs/remotes/<remote>/*fetch mapping; remotes with custom fetch mappings are skipped with a warning (this behavior is implemented inbranch_cleanup.rs). Server branches are not deleted by this assistant.with_transfer_undousage).Notes for reviewers
apply_branch_cleanup.---/+++markers; no run output was supplied, so please run it locally as part of review.If you want, I can list the public Tauri command names added and their parameter shapes, or extract the most important functions to test interactively.