Don't clear gui.git when we fail to open a repo

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) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller 2026-08-07 22:45:10 +02:00
parent e17ed2484c
commit ca6c0500e6

View file

@ -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 {