From d3804d313c1901ed5b791afd5fca0173d4c40ce0 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 1 Feb 2024 09:11:48 +0100 Subject: [PATCH] Fix a problem with refreshing while an update-ref todo is selected Scenario: - show the files of a commit, escape out of it again - start an interactive rebase of a stack of branches, with the rebase.updateRefs git config set to true - select one of the update-ref todos - trigger a refresh (either manually or by bringing lazygit's terminal window to the front) This results in an error message "fatal: ambiguous argument '': unknown revision or path not in the working tree." Fix this by putting another band-aid on the check for the commit files refresh. This is the easiest way to fix the problem, but I don't think it's the best one. We shouldn't be refreshing the commit files context at all if it isn't visible, because it's pointless; there's no way to switch to it again except by calling viewFiles again with a specific ref. But I'm too lazy too figure out how to do that right now. --- pkg/gui/controllers/helpers/refresh_helper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index a8f32d116..04b741b56 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -274,7 +274,7 @@ func (self *RefreshHelper) refreshCommitsAndCommitFiles() { // or perhaps we could just pop that context off the stack whenever cycling windows. // For now the awkwardness remains. commit := self.c.Contexts().LocalCommits.GetSelected() - if commit != nil { + if commit != nil && commit.RefName() != "" { self.c.Contexts().CommitFiles.SetRef(commit) self.c.Contexts().CommitFiles.SetTitleRef(commit.RefName()) _ = self.refreshCommitFilesContext()