From ca6c0500e61dce27f0bbd45c3bb876d0e37068a0 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 7 Aug 2026 22:45:10 +0200 Subject: [PATCH] Don't clear gui.git when we fail to open a repo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit onNewRepo also runs when switching repos, and a failure there leaves us in the repo we came from — with a nil GitCommand, which nothing else is prepared for. Only assign once we have one. Co-Authored-By: Claude Opus 5 (1M context) --- pkg/gui/gui.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index a7466d584..b92c1733e 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -340,8 +340,10 @@ func (gui *Gui) onSwitchToNewRepo(startArgs appTypes.StartArgs, contextKey types } func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.ContextKey) error { - var err error - gui.git, err = commands.NewGitCommand( + // Don't assign to gui.git until we know we have one: this also runs when + // switching repos, and leaving the field nil would take down the repo we + // were in before, which is where the error puts us back. + git, err := commands.NewGitCommand( gui.Common, gui.gitVersion, gui.os, @@ -351,6 +353,7 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.Context if err != nil { return err } + gui.git = git err = gui.Config.ReloadUserConfigForRepo(gui.getPerRepoConfigFiles()) if err != nil {