When checking out a remote branch by name, ask the user how

The choices are to create a new local branch that tracks the remote, or a
detached head.
This commit is contained in:
Stefan Haller 2024-03-15 20:56:44 +01:00
parent 0360b82aab
commit e42cbf95ae
4 changed files with 94 additions and 0 deletions

View file

@ -436,6 +436,10 @@ func (self *BranchesController) checkoutByName() error {
FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRefsSuggestionsFunc(),
HandleConfirm: func(response string) error {
self.c.LogAction("Checkout branch")
_, branchName, found := self.c.Helpers().Refs.ParseRemoteBranchName(response)
if found {
return self.c.Helpers().Refs.CheckoutRemoteBranch(response, branchName)
}
return self.c.Helpers().Refs.CheckoutRef(response, types.CheckoutRefOptions{
OnRefNotFound: func(ref string) error {
return self.c.Confirm(types.ConfirmOpts{