summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-03-28 11:27:05 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-03-28 11:59:45 +1100
commit036b53acf8234a719fa8e4652527d4781652e050 (patch)
tree9a557376385417dc56a922a6fd069f88499961d4
parent919463ff02266b6f6f9a0bbf0977b35654845537 (diff)
in fact we don't need any of these options
-rw-r--r--pkg/commands/git.go8
-rw-r--r--pkg/gui/commits_panel.go11
-rw-r--r--pkg/gui/reflog_panel.go8
3 files changed, 8 insertions, 19 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 1b0d6f4a5..f2a4706cc 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -1116,13 +1116,9 @@ func (c *GitCommand) FetchRemote(remoteName string) error {
return c.OSCommand.RunCommand("git fetch %s", remoteName)
}
-type GetReflogCommitsOptions struct {
- Recycle bool
-}
-
// GetReflogCommits only returns the new reflog commits since the given lastReflogCommit
// if none is passed (i.e. it's value is nil) then we get all the reflog commits
-func (c *GitCommand) GetReflogCommits(lastReflogCommit *Commit, options GetReflogCommitsOptions) ([]*Commit, bool, error) {
+func (c *GitCommand) GetReflogCommits(lastReflogCommit *Commit) ([]*Commit, bool, error) {
commits := make([]*Commit, 0)
re := regexp.MustCompile(`(\w+).*HEAD@\{([^\}]+)\}: (.*)`)
@@ -1143,7 +1139,7 @@ func (c *GitCommand) GetReflogCommits(lastReflogCommit *Commit, options GetReflo
Status: "reflog",
}
- if options.Recycle && lastReflogCommit != nil && commit.Sha == lastReflogCommit.Sha && commit.UnixTimestamp == lastReflogCommit.UnixTimestamp {
+ if lastReflogCommit != nil && commit.Sha == lastReflogCommit.Sha && commit.UnixTimestamp == lastReflogCommit.UnixTimestamp {
onlyObtainedNewReflogCommits = true
// after this point we already have these reflogs loaded so we'll simply return the new ones
return true, nil
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index 8293d25f0..7876a1a51 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -73,22 +73,19 @@ func (gui *Gui) handleCommitSelect(g *gocui.Gui, v *gocui.View) 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 get a small set of reflog entries so that we can ensure
-// the first couple of branches are correctly positioned. Then we asynchronously
-// refresh the reflog again, without a limit, and refresh the branches again when that's done.
-// When we're complete, we can begin recycling reflog entries because we know we've got
-// everything down to the oldest entry.
+// 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 func() {
- gui.refreshReflogCommits(refreshReflogOptions{Recycle: false})
+ gui.refreshReflogCommits()
gui.refreshBranches()
gui.State.StartupStage = COMPLETE
}()
case COMPLETE:
- gui.refreshReflogCommits(refreshReflogOptions{Recycle: true})
+ gui.refreshReflogCommits()
}
}
diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go
index f48778948..314509401 100644
--- a/pkg/gui/reflog_panel.go
+++ b/pkg/gui/reflog_panel.go
@@ -46,17 +46,13 @@ func (gui *Gui) handleReflogCommitSelect(g *gocui.Gui, v *gocui.View) error {
return nil
}
-type refreshReflogOptions struct {
- Recycle bool
-}
-
-func (gui *Gui) refreshReflogCommits(options refreshReflogOptions) error {
+func (gui *Gui) refreshReflogCommits() error {
var lastReflogCommit *commands.Commit
if len(gui.State.ReflogCommits) > 0 {
lastReflogCommit = gui.State.ReflogCommits[0]
}
- commits, onlyObtainedNewReflogCommits, err := gui.GitCommand.GetReflogCommits(lastReflogCommit, commands.GetReflogCommitsOptions(options))
+ commits, onlyObtainedNewReflogCommits, err := gui.GitCommand.GetReflogCommits(lastReflogCommit)
if err != nil {
return gui.createErrorPanel(gui.g, err.Error())
}