diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index 37ac90261..a51666ba1 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -746,7 +746,12 @@ func (self *BranchesController) rename(branch *models.Branch) error { } func (self *BranchesController) newBranch(selectedBranch *models.Branch) error { - return self.c.Helpers().Refs.NewBranch(selectedBranch.FullRefName(), selectedBranch.RefName(), "") + fromName := selectedBranch.RefName() + if selectedBranch.DetachedHead { + // The RefName of a detached HEAD is the full hash of its commit + fromName = models.CommitDescription(selectedBranch.Name, selectedBranch.Subject) + } + return self.c.Helpers().Refs.NewBranch(selectedBranch.FullRefName(), fromName, "") } func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Branch, checkedOutBranch *models.Branch) error { diff --git a/pkg/integration/tests/branch/detached_head.go b/pkg/integration/tests/branch/detached_head.go index 06f77a15c..368087e75 100644 --- a/pkg/integration/tests/branch/detached_head.go +++ b/pkg/integration/tests/branch/detached_head.go @@ -25,10 +25,7 @@ var DetachedHead = NewIntegrationTest(NewIntegrationTestArgs{ Press(keys.Universal.New) t.ExpectPopup().Prompt(). - /* EXPECTED: Title(MatchesRegexp(`^New branch name \(branch is off of '[0-9a-f]{7} commit-09'\)$`)). - ACTUAL: */ - Title(MatchesRegexp(`^New branch name \(branch is off of '[0-9a-f]{40}'\)$`)). Type("new-branch"). Confirm()