From 19604214d7da76a685085961095c1d7b2ad5f5cb Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 28 Mar 2020 10:45:44 +1100 Subject: discard old reflog commits when in new context --- pkg/gui/reflog_panel.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pkg/gui/reflog_panel.go') diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go index 199d9337f..d40467b28 100644 --- a/pkg/gui/reflog_panel.go +++ b/pkg/gui/reflog_panel.go @@ -52,12 +52,18 @@ func (gui *Gui) refreshReflogCommits() error { lastReflogCommit = gui.State.ReflogCommits[0] } - commits, err := gui.GitCommand.GetNewReflogCommits(lastReflogCommit) + commits, foundLastReflogCommit, err := gui.GitCommand.GetNewReflogCommits(lastReflogCommit) if err != nil { return gui.createErrorPanel(gui.g, err.Error()) } - gui.State.ReflogCommits = append(commits, gui.State.ReflogCommits...) + if foundLastReflogCommit { + gui.State.ReflogCommits = append(commits, gui.State.ReflogCommits...) + } else { + // if we haven't found it we're probably in a new repo so we don't want to + // retain the old reflog commits + gui.State.ReflogCommits = commits + } if gui.getCommitsView().Context == "reflog-commits" { return gui.renderReflogCommitsWithSelection() -- cgit v1.2.3