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.
This commit is contained in:
Stefan Haller 2024-02-01 09:11:48 +01:00
parent 8746c3d9e0
commit d3804d313c

View file

@ -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()