Repository navigation
set-parent: allow selecting a parent that is checked out in another worktree - #6298
Merged
Merged
Conversation
…orktree The dialogs that ask for a parent branch reuse the dialog of "git town switch", which disables branches that are active in another worktree because "git town switch" cannot check them out. This restriction does not apply when selecting a parent. Since the cursor skips disabled entries, the parent dialogs could not select such a branch, and moving past it could select the "make perennial" entry instead. Disable these branches only when the new SwitchBranchArgs.DisableBranchesInOtherWorktrees setting is enabled, which only "git town switch" does. This fixes the dialogs of "git town set-parent", "git town hack --beam", and the prompt for missing parent branches. Fixes #6279
Contributor
|
Thanks for building this! 💯 |
Contributor
Author
|
Thanks for the fast review! git-town makes stacked branches so much easier to live with, so I was glad to give a little back. |
Contributor
|
This is now available as part of Git Town 24.1.1. |
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 #6279
The dialog of
git town set-parentis built on the dialog ofgit town switch(dialog.SwitchBranch). That dialog disables branches that are active in another worktree (newSwitchBranchListEntriessetsDisabled: entry.OtherWorktree), becausegit town switchcannot check them out. This restriction doesn't apply when selecting a parent, and as noted in the issue,git town set-parent <branch>already accepts such a branch.Because the cursor skips disabled entries, the scenario from the issue does more than gray out the branch: pressing down on
mainwraps around to<none> (make perennial), so enter makes the current branch perennial.The same dialog asks for the parent in
git town hack --beamand when Git Town prompts for a missing parent branch, so these dialogs had the same problem.Changes
dialog.SwitchBranchArgsanddialog.SwitchModelget aDisableBranchesInOtherWorktreesfield. Branches in other worktrees are disabled only when it is set, also when a rebuilds the list.git town switchsets it totrue, so its behavior doesn't change. The three parent dialogs set it tofalse.+. In the parent dialogs they can now be selected.Tests
main, where down skips that branch and selects<none> (make perennial)instead:features/set_parent/worktree/new_parent_in_other_worktree.featurefeatures/diff_parent/worktree/parent_in_other_worktree.feature(prompt for a missing parent)features/hack/beam/parent_in_other_worktree.featureinternal/cli/dialog/switch_branch_test.gothat toggle the branch list with a, with and without the new setting.UNIT_TEST_DIRSfrom the Makefile), the full E2E suite,go vet, golangci-lint 2.12.2, staticcheck 2026.1, exhaustruct, gofumpt, the custom linters frommake lint, ghokin, gherkin-lint, and cucumber-sort. In the E2E suite, 2712 of 2724 scenarios pass. The 12 failing scenarios are in thelang/es.featurefiles and need Git's Spanish translations. They fail the same way onmainwithout them.