From 364bdcf53211b5e4709f5e69cbd3c909c6fb79ee Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 23 Aug 2020 17:28:28 +1000 Subject: safer getting of branch --- pkg/gui/files_panel.go | 7 ++++++- pkg/gui/status_panel.go | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index a8aa02436..c4798c854 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -423,8 +423,13 @@ func (gui *Gui) handlePullFiles(g *gocui.Gui, v *gocui.View) error { return nil } - // if we have no upstream branch we need to set that first currentBranch := gui.currentBranch() + if currentBranch == nil { + // need to wait for branches to refresh + return nil + } + + // if we have no upstream branch we need to set that first if currentBranch.Pullables == "?" { // see if we have this branch in our config with an upstream conf, err := gui.GitCommand.Repo.Config() diff --git a/pkg/gui/status_panel.go b/pkg/gui/status_panel.go index 2532cc96c..1f23ae6ec 100644 --- a/pkg/gui/status_panel.go +++ b/pkg/gui/status_panel.go @@ -67,6 +67,10 @@ func (gui *Gui) handleStatusClick(g *gocui.Gui, v *gocui.View) error { } currentBranch := gui.currentBranch() + if currentBranch == nil { + // need to wait for branches to refresh + return nil + } if err := gui.switchContext(gui.Contexts.Status.Context); err != nil { return err -- cgit v1.2.3