summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-03-26 21:12:12 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-03-26 21:44:33 +1100
commit21b7d4184535e1132c828c379c7125ecd100e02a (patch)
tree9b4741429f017fb529bab826a4b5455771d379d6
parent91a404d0331132d3aac463a4e77a7c73b81c5961 (diff)
relax limit on commit list and reset on branch change
-rw-r--r--pkg/commands/commit_list_builder.go13
-rw-r--r--pkg/gui/branches_panel.go17
-rw-r--r--pkg/gui/commits_panel.go2
-rw-r--r--pkg/gui/reset_menu_panel.go2
4 files changed, 19 insertions, 15 deletions
diff --git a/pkg/commands/commit_list_builder.go b/pkg/commands/commit_list_builder.go
index 7f7a979b5..a39ab7593 100644
--- a/pkg/commands/commit_list_builder.go
+++ b/pkg/commands/commit_list_builder.go
@@ -299,18 +299,11 @@ func (c *CommitListBuilder) getUnpushedCommits() map[string]bool {
}
// getLog gets the git log.
-func (c *CommitListBuilder) getLog(limit bool) string {
+func (c *CommitListBuilder) getLogCmd(limit bool) *exec.Cmd {
limitFlag := ""
if limit {
- limitFlag = "-30"
+ limitFlag = "-300"
}
- result, err := c.OSCommand.RunCommandWithOutput(fmt.Sprintf("git log --oneline --pretty=format:\"%%H%s%%ar%s%%aN%s%%d%s%%s\" %s --abbrev=%d", SEPARATION_CHAR, SEPARATION_CHAR, SEPARATION_CHAR, SEPARATION_CHAR, limitFlag, 20))
-
- if err != nil {
- // assume if there is an error there are no commits yet for this branch
- return ""
- }
-
- return result
+ return c.OSCommand.ExecutableFromString(fmt.Sprintf("git log --oneline --pretty=format:\"%%H%s%%ar%s%%aN%s%%d%s%%s\" %s --abbrev=%d", SEPARATION_CHAR, SEPARATION_CHAR, SEPARATION_CHAR, SEPARATION_CHAR, limitFlag, 20))
}
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 399b46bde..6ca257ed4 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -156,6 +156,13 @@ func (gui *Gui) handleCheckoutRef(ref string, options handleCheckoutRefOptions)
cmdOptions := commands.CheckoutOptions{Force: false, EnvVars: options.EnvVars}
+ onSuccess := func() {
+ gui.State.Panels.Branches.SelectedLine = 0
+ gui.State.Panels.Commits.SelectedLine = 0
+ // loading a heap of commits is slow so we limit them whenever doing a reset
+ gui.State.Panels.Commits.LimitCommits = true
+ }
+
return gui.WithWaitingStatus(waitingStatus, func() error {
if err := gui.GitCommand.Checkout(ref, cmdOptions); err != nil {
// note, this will only work for english-language git commands. If we force git to use english, and the error isn't this one, then the user will receive an english command they may not understand. I'm not sure what the best solution to this is. Running the command once in english and a second time in the native language is one option
@@ -171,8 +178,7 @@ func (gui *Gui) handleCheckoutRef(ref string, options handleCheckoutRefOptions)
return gui.createErrorPanel(g, err.Error())
}
- // checkout successful so we select the new branch
- gui.State.Panels.Branches.SelectedLine = 0
+ onSuccess()
if err := gui.GitCommand.StashDo(0, "pop"); err != nil {
if err := gui.refreshSidePanels(g); err != nil {
@@ -189,8 +195,8 @@ func (gui *Gui) handleCheckoutRef(ref string, options handleCheckoutRefOptions)
}
}
- gui.State.Panels.Branches.SelectedLine = 0
- gui.State.Panels.Commits.SelectedLine = 0
+ onSuccess()
+
return gui.refreshSidePanels(gui.g)
})
}
@@ -492,5 +498,8 @@ func (gui *Gui) handleRenameBranch(g *gocui.Gui, v *gocui.View) error {
}
func (gui *Gui) currentBranch() *commands.Branch {
+ if len(gui.State.Branches) == 0 {
+ return nil
+ }
return gui.State.Branches[0]
}
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go
index 7b620e571..25be221d7 100644
--- a/pkg/gui/commits_panel.go
+++ b/pkg/gui/commits_panel.go
@@ -35,7 +35,7 @@ func (gui *Gui) handleCommitSelect(g *gocui.Gui, v *gocui.View) error {
}
state := gui.State.Panels.Commits
- if state.SelectedLine > 20 && state.LimitCommits {
+ if state.SelectedLine > 290 && state.LimitCommits {
state.LimitCommits = false
go func() {
if err := gui.refreshCommitsWithLimit(); err != nil {
diff --git a/pkg/gui/reset_menu_panel.go b/pkg/gui/reset_menu_panel.go
index 5103044a2..05bdb5e9b 100644
--- a/pkg/gui/reset_menu_panel.go
+++ b/pkg/gui/reset_menu_panel.go
@@ -18,6 +18,8 @@ func (gui *Gui) resetToRef(ref string, strength string, options commands.RunComm
gui.State.Panels.Commits.SelectedLine = 0
gui.State.Panels.ReflogCommits.SelectedLine = 0
+ // loading a heap of commits is slow so we limit them whenever doing a reset
+ gui.State.Panels.Commits.LimitCommits = true
if err := gui.refreshCommits(gui.g); err != nil {
return err