diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 4bfd50437..f4fde0e89 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -791,8 +791,9 @@ func (c *GitCommand) ApplyPatch(patch string, flags ...string) error { return c.OSCommand.RunCommand("git apply %s %s", flagStr, c.OSCommand.Quote(filepath)) } -func (c *GitCommand) FastForward(branchName string, remoteName string, remoteBranchName string) error { - return c.OSCommand.RunCommand("git fetch %s %s:%s", remoteName, remoteBranchName, branchName) +func (c *GitCommand) FastForward(branchName string, remoteName string, remoteBranchName string, promptUserForCredential func(string) string) error { + command := fmt.Sprintf("git fetch %s %s:%s", remoteName, remoteBranchName, branchName) + return c.OSCommand.DetectUnamePass(command, promptUserForCredential) } func (c *GitCommand) RunSkipEditorCommand(command string) error { diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 1341702f7..ed8e7819e 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -400,16 +400,11 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error { if gui.State.Panels.Branches.SelectedLine == 0 { _ = gui.pullWithMode("ff-only", PullFilesOptions{}) - return } else { - if err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName); err != nil { - _ = gui.surfaceError(err) - return - } + err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName, gui.promptUserForCredential) + gui.handleCredentialsPopup(err) _ = gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{BRANCHES}}) } - - _ = gui.closeConfirmationPrompt(gui.g, true) }() return nil }