diff options
Diffstat (limited to 'pkg/gui/commits_panel.go')
-rw-r--r-- | pkg/gui/commits_panel.go | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 26b3fac09..b2233f377 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -1,11 +1,7 @@ package gui import ( - "sync" - - "github.com/jesseduffield/lazygit/pkg/commands/loaders" "github.com/jesseduffield/lazygit/pkg/commands/models" - "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/utils" ) @@ -58,81 +54,6 @@ func (gui *Gui) branchCommitsRenderToMain() error { }) } -// during startup, the bottleneck is fetching the reflog entries. We need these -// on startup to sort the branches by recency. So we have two phases: INITIAL, and COMPLETE. -// In the initial phase we don't get any reflog commits, but we asynchronously get them -// and refresh the branches after that -func (gui *Gui) refreshReflogCommitsConsideringStartup() { - switch gui.State.StartupStage { - case INITIAL: - go utils.Safe(func() { - _ = gui.refreshReflogCommits() - gui.refreshBranches() - gui.State.StartupStage = COMPLETE - }) - - case COMPLETE: - _ = gui.refreshReflogCommits() - } -} - -// whenever we change commits, we should update branches because the upstream/downstream -// counts can change. Whenever we change branches we should probably also change commits -// e.g. in the case of switching branches. -func (gui *Gui) refreshCommits() { - wg := sync.WaitGroup{} - wg.Add(2) - - go utils.Safe(func() { - gui.refreshReflogCommitsConsideringStartup() - - gui.refreshBranches() - wg.Done() - }) - - go utils.Safe(func() { - _ = gui.refreshCommitsWithLimit() - ctx, ok := gui.State.Contexts.CommitFiles.GetParentContext() - if ok && ctx.GetKey() == context.BRANCH_COMMITS_CONTEXT_KEY { - // This makes sense when we've e.g. just amended a commit, meaning we get a new commit SHA at the same position. - // However if we've just added a brand new commit, it pushes the list down by one and so we would end up - // showing the contents of a different commit than the one we initially entered. - // Ideally we would know when to refresh the commit files context and when not to, - // or perhaps we could just pop that context off the stack whenever cycling windows. - // For now the awkwardness remains. - commit := gui.getSelectedLocalCommit() - if commit != nil { - gui.State.Panels.CommitFiles.refName = commit.RefName() - _ = gui.refreshCommitFilesView() - } - } - wg.Done() - }) - - wg.Wait() -} - -func (gui *Gui) refreshCommitsWithLimit() error { - gui.Mutexes.BranchCommitsMutex.Lock() - defer gui.Mutexes.BranchCommitsMutex.Unlock() - - commits, err := gui.git.Loaders.Commits.GetCommits( - loaders.GetCommitsOptions{ - Limit: gui.State.Panels.Commits.LimitCommits, - FilterPath: gui.State.Modes.Filtering.GetPath(), - IncludeRebaseCommits: true, - RefName: gui.refForLog(), - All: gui.ShowWholeGitGraph, - }, - ) - if err != nil { - return err - } - gui.State.Commits = commits - - return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits) -} - func (gui *Gui) refForLog() string { bisectInfo := gui.git.Bisect.GetInfo() gui.State.BisectInfo = bisectInfo @@ -148,16 +69,3 @@ func (gui *Gui) refForLog() string { return bisectInfo.GetStartSha() } - -func (gui *Gui) refreshRebaseCommits() error { - gui.Mutexes.BranchCommitsMutex.Lock() - defer gui.Mutexes.BranchCommitsMutex.Unlock() - - updatedCommits, err := gui.git.Loaders.Commits.MergeRebasingCommits(gui.State.Commits) - if err != nil { - return err - } - gui.State.Commits = updatedCommits - - return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits) -} |