Repository navigation
[Worktree] Find a worktree again after its folder was moved (part 5) - #731
Conversation
6db57ed to
1acebef
Compare
9e93e8f to
9b960de
Compare
9b960de to
290c450
Compare
1804a03 to
4662c74
Compare
b924929 to
f48323c
Compare
4662c74 to
69aad3a
Compare
f48323c to
8150610
Compare
69aad3a to
172ccb1
Compare
Let a worktree whose folder went missing be pointed at where the folder went, so git connects it again instead of offering only to prune it. - Offer "Locate Worktree Folder..." in place of Reveal while a worktree's folder is missing, and a "Locate Folder..." button on the missing-folder sheet; both run `git worktree repair` (git 2.29) - Refuse a folder that already belongs to a worktree, and report it when git connected the chosen folder to some other worktree - Disable the item with the version it needs on an older git
172ccb1 to
7b406b8
Compare
|
Following #675 means, that this is probably the last one for worktree. Does it make sense, after this merge, to create a new worktree-release ? |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Address the main-thread blocking and repair-verification issues, plus the missing-path directory check.
Review effort: Lite
Findings: None
What changed in this PR
Adds support for locating moved worktree folders via git worktree repair, with version gating, validation, UI actions, and tests.
Changes:
- Adds worktree repair and verification logic.
- Adds Locate Folder actions and missing-folder UI.
- Adds Git version and repair scenario tests.
| File | Description |
|---|---|
GitXTests/PBGitWorktreeManagementTests.m |
Tests repair behavior and UI flows. |
GitXTests/PBGitBinaryVersionTests.m |
Tests the Git version boundary. |
Classes/git/PBGitRepository.m |
Implements repair and validation. |
Classes/git/PBGitRepository.h |
Exposes the repair API. |
Classes/git/PBGitBinary.h |
Defines the repair version requirement. |
Classes/Controllers/PBGitWindowController.m |
Adds folder-selection and repair UI. |
Classes/Controllers/PBGitWindowController.h |
Declares the locate action. |
Classes/Controllers/PBGitHistoryController.m |
Switches menu actions for missing folders. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Yes, I think so. We've also improved support for dark/light mode and solved quite a few annoying bugs, so feels like it deserves a release. |
|
Thanks for the worktree support, really appreciate these improvements to gitx |

Slice 5 of #675: find a worktree again after its folder was moved, the way Tower offers to repair one,
instead of offering only to prune it.
(It builds on #727 (slice 4) and targets its branch so the diff shows this slice alone; merge #723 and #727 first.)
Changes
While a worktree's folder is missing, Locate Worktree Folder... takes the place of Reveal Worktree in Finder, which had nothing to reveal, the same way Lock and Unlock trade places. The sidebar row and the branch label in the history list stay identical:
The missing-folder sheet (double-clicking a dimmed worktree) gains a Locate Folder... button and a sentence saying what it is for.
Locating opens a folder panel at the worktree's old location and runs
git worktree repair <folder>. It works on a locked worktree too, which stays locked.A wrong folder is caught: git's own error is shown for a folder that is no worktree. Two cases git lets through are checked by GitX: a folder that already belongs to a worktree is refused before git runs, and when the chosen folder is another moved worktree's (git quietly repairs that one and exits 0), GitX reports that the worktree asked about is still missing.
Screenshots
Missing Worktree - Grayed-out and "Prunable":
Missing Worktree - Can Prune:
Missing Worktree - Can Locate:
Older git
git worktree repairarrived in git 2.29. Following the plan agreed on the issue (comment) and the version check #723 adds, Locate Worktree Folder... is shown disabled before 2.29 with a tooltip naming the version needed and the one found, and the sheet offers no Locate Folder... button.Repairing after the main repository's folder moves (
git worktree repairwith no path) is not part of this slice.Test plan
make unit-test: 289 tests, 10 of them new: the 2.28.1/2.29 boundary; repairing a moved worktree and a moved locked one against a real repository; refusing another worktree's folder, a plain folder, and another moved worktree's folder; the menu swap in both menus and on an older git; and the sheet's buttons.git worktree listthen shows the new path and GitX's list follows), the menu action reaching the window controller, and choosing the main worktree's folder refused with its reason.