From d924a26737a812fd34e2358abf29103c85ef69d7 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 20:34:47 +0100 Subject: [PATCH 01/26] Fix the parameter names of Shell.StartBisect `git bisect start` takes the bad commit first and the good one second. The parameters were named the other way round. The only caller already passes the bad commit first, so only the names were wrong. Co-Authored-By: Claude Opus 5.5 --- pkg/integration/components/shell.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go index 72cc3d95c..e64646779 100644 --- a/pkg/integration/components/shell.go +++ b/pkg/integration/components/shell.go @@ -414,8 +414,8 @@ func (self *Shell) Stash(message string) *Shell { return self } -func (self *Shell) StartBisect(good string, bad string) *Shell { - self.RunCommand([]string{"git", "bisect", "start", good, bad}) +func (self *Shell) StartBisect(bad string, good string) *Shell { + self.RunCommand([]string{"git", "bisect", "start", bad, good}) return self } From cd23678775509ddd83e789540d6731e0af54a2a2 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 20:35:41 +0100 Subject: [PATCH 02/26] Re-render the commits view in the same UI-thread hop as its model update The commits refresh updated the model and the selection in one hop to the UI thread, and re-rendered the view in a second one. The scroll behavior of the re-render was fixed when the refresh started. The next commit makes the scroll behavior depend on how the refresh changed the selection. Do both in one hop, so that the re-render can see that. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/controllers/helpers/refresh_helper.go | 52 ++++++++++++------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 4b3d1c429..b919eb84b 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -134,6 +134,14 @@ type refreshEnv struct { batch *refreshBounceBatch } +// focusOpts returns the options for re-rendering the views this refresh updates. +func (env refreshEnv) focusOpts() types.OnFocusOpts { + return types.OnFocusOpts{ + KeepScrollPosition: env.keepScrollPosition, + SkipMainViewUpdate: env.skipMainViewUpdate, + } +} + // refreshBounceBatch collects the UI-thread bounces of a batched refresh so they // can be applied together in one frame rather than one scope at a time. The // scopes run on separate worker goroutines and add concurrently, hence the @@ -897,9 +905,10 @@ func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, case types.KeepCommitSelectionIndex: // The caller set the selection index deliberately; leave it untouched. } + + self.rerenderView(self.c.Contexts().LocalCommits, env.focusOpts()) }) - self.refreshView(self.c.Contexts().LocalCommits, env) return nil } @@ -1725,27 +1734,30 @@ func (self *RefreshHelper) refreshView(context types.Context, env refreshEnv) { // dropped, so there's nothing fresh to render — and the captured context // belongs to the old repo's now-replaced context tree anyway. self.onUIThreadUnlessRepoChanged(env, func() { - // Re-applying the filter must be done before re-rendering the view, so that - // the filtered list model is up to date for rendering. - self.searchHelper.ReApplyFilter(context) + self.rerenderView(context, env.focusOpts()) + }) +} - self.c.PostRefreshUpdateWithOptions(context, types.OnFocusOpts{ - KeepScrollPosition: env.keepScrollPosition, - SkipMainViewUpdate: env.skipMainViewUpdate, - }) +// rerenderView re-renders a context's view after a refresh has updated the +// model it shows. It must run on the UI thread. +func (self *RefreshHelper) rerenderView(context types.Context, opts types.OnFocusOpts) { + // Re-applying the filter must be done before re-rendering the view, so that + // the filtered list model is up to date for rendering. + self.searchHelper.ReApplyFilter(context) - self.c.AfterLayout(func() error { - // Re-applying the search must be done after re-rendering the view though, - // so that the "x of y" status is shown correctly. - // - // Also, it must be done after layout, because otherwise FocusPoint - // hasn't been called yet (see ListContextTrait.FocusLine), which means - // that the scroll position might be such that the entire visible - // content is outside the viewport. And this would cause problems in - // searchModelCommits. - self.searchHelper.ReApplySearch(context) - return nil - }) + self.c.PostRefreshUpdateWithOptions(context, opts) + + self.c.AfterLayout(func() error { + // Re-applying the search must be done after re-rendering the view though, + // so that the "x of y" status is shown correctly. + // + // Also, it must be done after layout, because otherwise FocusPoint + // hasn't been called yet (see ListContextTrait.FocusLine), which means + // that the scroll position might be such that the entire visible + // content is outside the viewport. And this would cause problems in + // searchModelCommits. + self.searchHelper.ReApplySearch(context) + return nil }) } From 30744324f89b5c4e747dcf98b3002e44fdfe9304 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 20:37:44 +0100 Subject: [PATCH 03/26] Add a test showing that a background refresh doesn't scroll to a conflict If a rebase started outside of lazygit stops with a conflict, the next background refresh selects the conflicted commit. It keeps the scroll position though, so if there are enough pending todos above the conflicted commit, the selection is off-screen. Co-Authored-By: Claude Opus 5.5 --- pkg/integration/tests/test_list.go | 1 + ...nd_refresh_scrolls_to_conflicted_commit.go | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 36b71ea00..17f97924c 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -655,6 +655,7 @@ var tests = []*components.IntegrationTest{ tag.ResetToDuplicateNamedBranch, ui.Accordion, ui.BackgroundRefreshKeepsScrollPosition, + ui.BackgroundRefreshScrollsToConflictedCommit, ui.BranchesNotFirstTab, ui.CommitsNotFirstTab, ui.DisableSwitchTabWithPanelJumpKeys, diff --git a/pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go b/pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go new file mode 100644 index 000000000..ea4c0b308 --- /dev/null +++ b/pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go @@ -0,0 +1,40 @@ +package ui + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var BackgroundRefreshScrollsToConflictedCommit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "A background refresh that selects a newly conflicted commit scrolls it into view", + ExtraCmdArgs: []string{}, + Skip: false, + Width: 120, + Height: 30, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("initial commit") + shell.CreateFileAndAdd("file.txt", "master content") + shell.Commit("master commit") + shell.NewBranchFrom("branch", "master^") + shell.CreateFileAndAdd("file.txt", "branch content") + shell.Commit("this will conflict") + shell.CreateNCommits(30) + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + SelectedLine(Contains("commit-30")). + Tap(func() { + t.Shell().RunCommandExpectError([]string{"git", "rebase", "master"}) + t.RefreshInBackground() + }). + // The conflicted commit, below the 30 pending todos and their header + SelectedLineIdx(31). + /* EXPECTED: + SelectedLineIsVisible(). + SelectedLine(Contains("<-- CONFLICT --- this will conflict")) + ACTUAL: */ + OriginY(0) + }, +}) From 550a6d88a74fbfcd6dfa1d5fa3c4f47ece334f78 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 20:37:56 +0100 Subject: [PATCH 04/26] Scroll a newly conflicted commit into view in background refreshes When a refresh finds a new conflicted commit, it selects it so that the user sees where the rebase stopped. A background refresh keeps the scroll position of the views it updates though. If the conflicted commit is outside the visible part of the commits view, the selection moves to a commit that the user can't see. Scroll the selection into view whenever the refresh moves it to a newly conflicted commit. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/controllers/helpers/refresh_helper.go | 9 ++++++++- .../background_refresh_scrolls_to_conflicted_commit.go | 3 --- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index b919eb84b..e8477c35b 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -906,7 +906,14 @@ func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, // The caller set the selection index deliberately; leave it untouched. } - self.rerenderView(self.c.Contexts().LocalCommits, env.focusOpts()) + focusOpts := env.focusOpts() + if newConflictedCommitIdx != nil { + // We selected a commit that the user needs to look at next, so + // scroll it into view even if the refresh keeps the scroll position + // otherwise. + focusOpts.KeepScrollPosition = false + } + self.rerenderView(self.c.Contexts().LocalCommits, focusOpts) }) return nil diff --git a/pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go b/pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go index ea4c0b308..e0c1d1605 100644 --- a/pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go +++ b/pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go @@ -31,10 +31,7 @@ var BackgroundRefreshScrollsToConflictedCommit = NewIntegrationTest(NewIntegrati }). // The conflicted commit, below the 30 pending todos and their header SelectedLineIdx(31). - /* EXPECTED: SelectedLineIsVisible(). SelectedLine(Contains("<-- CONFLICT --- this will conflict")) - ACTUAL: */ - OriginY(0) }, }) From 208bbce33fe0dc5a75462eeca2c68a21948ed696 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 20:40:57 +0100 Subject: [PATCH 05/26] Select the current bisect commit whenever it changes If lazygit starts while a bisect is in progress, the commits view selects the top commit, and the user has to look for the commit that git wants them to test. The same happens when a git bisect command run outside of lazygit moves the bisect on. The bisect menu selected the new current commit after a good, bad or skip, but only if the selected commit was the current one. It also needed extra logic to wait for the refresh in case the log was going to start from a different ref. Remove that, and let the commits refresh select the current commit whenever it differs from the one at the previous refresh, like it does for a newly conflicted commit. A refresh that doesn't change it leaves the selection alone. This way a background fetch doesn't move the selection back to the current commit after the user navigated away from it. Marking the current commit as good or bad while a different commit is selected now selects the new current commit too. Skipping the selected commit when it isn't the current one is an exception. Git often picks a different commit to test after that, but we keep the skipped commit selected, so that the user can go on skipping commits near it. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/controllers/bisect_controller.go | 71 +++---------------- pkg/gui/controllers/helpers/refresh_helper.go | 42 +++++++++-- .../tests/bisect/from_other_branch.go | 5 +- .../tests/bisect/select_current_commit.go | 35 +++++++++ pkg/integration/tests/test_list.go | 1 + 5 files changed, 84 insertions(+), 70 deletions(-) create mode 100644 pkg/integration/tests/bisect/select_current_commit.go diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index 685f932b1..b6c82d49c 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -6,7 +6,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" - "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" @@ -59,20 +58,6 @@ func (self *BisectController) openMenu(commit *models.Commit) error { } func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, commit *models.Commit) error { - // if there is not yet a 'current' bisect commit, or if we have - // selected the current commit, we need to jump to the next 'current' commit - // after we perform a bisect action. The reason we don't unconditionally jump - // is that sometimes the user will want to go and mark a few commits as skipped - // in a row and they wouldn't want to be jumped back to the current bisect - // commit each time. - // Originally we were allowing the user to, from the bisect menu, select whether - // they were talking about the selected commit or the current bisect commit, - // and that was a bit confusing (and required extra keypresses). - selectCurrentAfter := info.GetCurrentHash() == "" || info.GetCurrentHash() == commit.Hash() - // we need to wait to reselect if our bisect commits aren't ancestors of our 'start' - // ref, because we'll be reloading our commits in that case. - waitToReselect := selectCurrentAfter && !self.c.Git().Bisect.ReachableFromStart(info) - // If we have a current hash already, then we always want to use that one. If // not, we're still picking the initial commits before we really start, so // use the selected commit in that case. @@ -98,7 +83,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c return err } - return self.afterMark(selectCurrentAfter, waitToReselect) + return self.afterMark(types.KeepCommitSelectionByHash) }, DisabledReason: singleItemIfNotBisecting, Keys: menuKey('b'), @@ -111,7 +96,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c return err } - return self.afterMark(selectCurrentAfter, waitToReselect) + return self.afterMark(types.KeepCommitSelectionByHash) }, DisabledReason: singleItemIfNotBisecting, Keys: menuKey('g'), @@ -124,7 +109,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c return err } - return self.afterMark(selectCurrentAfter, waitToReselect) + return self.afterMark(types.KeepCommitSelectionByHash) }, DisabledReason: singleItemIfNotBisecting, Keys: menuKey('s'), @@ -139,7 +124,10 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c return err } - return self.afterMark(selectCurrentAfter, waitToReselect) + // Git may pick a different commit to test now. Keep the skipped + // commit selected anyway, so that the user can go on skipping + // commits near it. + return self.afterMark(types.KeepCommitSelectionIndex) }, DisabledReason: self.require(self.singleItemSelected())(), Keys: menuKey('S'), @@ -256,15 +244,13 @@ func (self *BisectController) showBisectCompleteMessage(candidateHashes []string return nil } -func (self *BisectController) afterMark(selectCurrent bool, waitToReselect bool) error { +func (self *BisectController) afterMark(commitSelection types.CommitSelectionBehavior) error { done, candidateHashes, err := self.c.Git().Bisect.IsDone() if err != nil { return err } - if err := self.afterBisectMarkRefresh(selectCurrent, waitToReselect); err != nil { - return err - } + self.c.Refresh(types.RefreshOptions{CommitSelection: commitSelection}) if done { return self.showBisectCompleteMessage(candidateHashes) @@ -272,42 +258,3 @@ func (self *BisectController) afterMark(selectCurrent bool, waitToReselect bool) return nil } - -func (self *BisectController) afterBisectMarkRefresh(selectCurrent bool, waitToReselect bool) error { - selectFn := func() error { - if selectCurrent { - self.selectCurrentBisectCommit() - } - return nil - } - - if waitToReselect { - self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{}, Then: selectFn}) - return nil - } - - if err := selectFn(); err != nil { - return err - } - - self.c.Helpers().Bisect.PostBisectCommandRefresh() - return nil -} - -func (self *BisectController) selectCurrentBisectCommit() { - info := self.c.Git().Bisect.GetInfo() - if info.GetCurrentHash() != "" { - // find index of commit with that hash, move cursor to that. - for i, commit := range self.c.Model().Commits { - if commit.Hash() == info.GetCurrentHash() { - self.context().SetSelection(i) - self.context().HandleFocus(types.OnFocusOpts{}) - break - } - } - } -} - -func (self *BisectController) context() *context.LocalCommitsContext { - return self.c.Contexts().LocalCommits -} diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index e8477c35b..4a7aa6f0c 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -870,11 +870,14 @@ func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, self.onUIThreadUnlessRepoChanged(env, func() { var selectionRange *localCommitSelectionRange - var newConflictedCommitIdx *int + var jumpToCommitIdx *int if commitSelection == types.KeepCommitSelectionByHash { selectedIdx, rangeStartIdx, rangeSelectMode := self.c.Contexts().LocalCommits.GetSelectionRangeAndMode() selectionRange = captureLocalCommitSelectionRange(self.c.Model().Commits, selectedIdx, rangeStartIdx, rangeSelectMode) - newConflictedCommitIdx = findNewConflictedCommit(self.c.Model().Commits, commits) + jumpToCommitIdx = findNewConflictedCommit(self.c.Model().Commits, commits) + if jumpToCommitIdx == nil { + jumpToCommitIdx = findNewBisectCommitToSelect(self.c.Model().BisectInfo, bisectInfo, commits) + } } self.c.Model().BisectInfo = bisectInfo @@ -894,8 +897,8 @@ func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, self.c.Contexts().LocalCommits.SetSelection(headCommitIdx) } case types.KeepCommitSelectionByHash: - if newConflictedCommitIdx != nil { - self.c.Contexts().LocalCommits.SetSelection(*newConflictedCommitIdx) + if jumpToCommitIdx != nil { + self.c.Contexts().LocalCommits.SetSelection(*jumpToCommitIdx) } else if selectionRange != nil { selectedIdx, rangeStartIdx, found := findLocalCommitSelectionRange(commits, selectionRange) if found { @@ -907,7 +910,7 @@ func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, } focusOpts := env.focusOpts() - if newConflictedCommitIdx != nil { + if jumpToCommitIdx != nil { // We selected a commit that the user needs to look at next, so // scroll it into view even if the refresh keeps the scroll position // otherwise. @@ -1007,6 +1010,35 @@ func findNewConflictedCommit(previousCommits []*models.Commit, commits []*models return nil } +// Returns the index of the commit that the user needs to look at during a +// bisect, if it is in the new commits slice and it is a different commit than +// at the previous refresh (or there wasn't one then). Otherwise returns nil. +func findNewBisectCommitToSelect(previousBisectInfo *git_commands.BisectInfo, bisectInfo *git_commands.BisectInfo, commits []*models.Commit) *int { + hash := bisectCommitToSelect(bisectInfo) + if hash == "" || hash == bisectCommitToSelect(previousBisectInfo) { + return nil + } + + _, idx, found := lo.FindIndexOf(commits, func(commit *models.Commit) bool { + return commit.Hash() == hash + }) + if found { + return &idx + } + + return nil +} + +// Returns the commit that the user needs to look at during a bisect: the one +// that git wants them to test. Returns "" if there's none. +func bisectCommitToSelect(bisectInfo *git_commands.BisectInfo) string { + if !bisectInfo.Bisecting() { + return "" + } + + return bisectInfo.GetCurrentHash() +} + // capturedSubCommitState holds the sub-commits refresh's model/context/mode // inputs, gathered on the UI thread (see captureSubCommitState) before the git // work is dispatched to a worker. diff --git a/pkg/integration/tests/bisect/from_other_branch.go b/pkg/integration/tests/bisect/from_other_branch.go index b65c88594..77d4904c9 100644 --- a/pkg/integration/tests/bisect/from_other_branch.go +++ b/pkg/integration/tests/bisect/from_other_branch.go @@ -6,7 +6,7 @@ import ( ) var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Opening lazygit when bisect has been started from another branch. There's an issue where we don't reselect the current branch if we mark the current branch as bad so this test side-steps that problem", + Description: "Opening lazygit when bisect has been started from another branch", ExtraCmdArgs: []string{}, Skip: false, SetupRepo: func(shell *Shell) { @@ -25,11 +25,10 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{ Focus(). TopLines( MatchesRegexp(`<-- bad.*commit-08`), - MatchesRegexp(`<-- current.*commit-07`), + MatchesRegexp(`<-- current.*commit-07`).IsSelected(), MatchesRegexp(`\?.*commit-06`), MatchesRegexp(`<-- good.*commit-05`), ). - SelectNextItem(). Press(keys.Commits.ViewBisectOptions). Tap(func() { t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as good`)).Confirm() diff --git a/pkg/integration/tests/bisect/select_current_commit.go b/pkg/integration/tests/bisect/select_current_commit.go new file mode 100644 index 000000000..4f575eae6 --- /dev/null +++ b/pkg/integration/tests/bisect/select_current_commit.go @@ -0,0 +1,35 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SelectCurrentCommit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Select the current bisect commit whenever it changes, but not on every refresh", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(10). + StartBisect("HEAD", "HEAD~9") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + SelectedLine(Contains("CI commit-05").Contains("<-- current")). + NavigateToLine(Contains("CI commit-08")). + Tap(func() { + t.RefreshInBackground() + }). + SelectedLine(Contains("CI commit-08")). + Tap(func() { + t.Shell().RunCommand([]string{"git", "bisect", "good"}) + t.RefreshInBackground() + }). + SelectedLine(Contains("CI commit-07").Contains("<-- current")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 17f97924c..3fab3959d 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -38,6 +38,7 @@ var tests = []*components.IntegrationTest{ bisect.Basic, bisect.ChooseTerms, bisect.FromOtherBranch, + bisect.SelectCurrentCommit, bisect.Skip, branch.CheckoutAutostash, branch.CheckoutByName, From 4725e80b343c58efec7f1104df53d9f1452ac344 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 20:42:55 +0100 Subject: [PATCH 06/26] Add a test showing that a checkout before bisecting doesn't update the log Once a bisect has started, the commits view shows the log of the branch that was checked out when it started. This happens even while we don't know both a good and a bad commit yet, and git hasn't checked out anything for the user to test. If the user checks out a different branch to mark its head as bad, the commits view keeps showing the old branch, so the new branch's head isn't there to be marked. Co-Authored-By: Claude Opus 5.5 --- .../check_out_branch_before_bisecting.go | 62 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 63 insertions(+) create mode 100644 pkg/integration/tests/bisect/check_out_branch_before_bisecting.go diff --git a/pkg/integration/tests/bisect/check_out_branch_before_bisecting.go b/pkg/integration/tests/bisect/check_out_branch_before_bisecting.go new file mode 100644 index 000000000..b9e7d2bbf --- /dev/null +++ b/pkg/integration/tests/bisect/check_out_branch_before_bisecting.go @@ -0,0 +1,62 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var CheckOutBranchBeforeBisecting = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Check out a different branch after marking a commit as good, but before marking one as bad", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(3). + NewBranch("feature"). + CreateNCommitsStartingAt(3, 4). + Checkout("master") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + SelectedLine(Contains("CI commit-03")). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as good`)).Confirm() + }). + Lines( + Contains("CI commit-03").Contains("<-- good"), + Contains("CI commit-02"), + Contains("CI commit-01"), + ) + + t.Views().Branches(). + Focus(). + NavigateToLine(Contains("feature")). + PressPrimaryAction(). + Lines( + Contains("* feature"), + Contains("master"), + ) + + t.Views().Commits(). + /* EXPECTED: + Lines( + Contains("CI commit-06"), + Contains("CI commit-05"), + Contains("CI commit-04"), + Contains("CI commit-03").Contains("<-- good"), + Contains("CI commit-02"), + Contains("CI commit-01"), + ) + ACTUAL: */ + Lines( + Contains("CI commit-03").Contains("<-- good"), + Contains("CI commit-02"), + Contains("CI commit-01"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 3fab3959d..15aa27ea5 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -36,6 +36,7 @@ import ( var tests = []*components.IntegrationTest{ bisect.Basic, + bisect.CheckOutBranchBeforeBisecting, bisect.ChooseTerms, bisect.FromOtherBranch, bisect.SelectCurrentCommit, From 8055f5c1398eec61a5ab38b53d7af70240ff627a Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 20:44:50 +0100 Subject: [PATCH 07/26] Show the log of HEAD until both a good and a bad commit are known Once a bisect had started, the commits view showed the log of the branch that was checked out when it started, even while git was still waiting for a good or a bad commit. If the user checked out a different branch to mark its head as bad, its commits weren't shown. Keep showing the log of HEAD until git starts checking out commits to test. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/controllers/helpers/refresh_helper.go | 8 ++++++-- .../tests/bisect/check_out_branch_before_bisecting.go | 7 ------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 4a7aa6f0c..c367fd80b 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -1753,12 +1753,16 @@ func (self *RefreshHelper) refreshStatus(env refreshEnv) { func (self *RefreshHelper) refForLog(env refreshEnv) (string, *git_commands.BisectInfo) { bisectInfo := env.git.Bisect.GetInfo() - if !bisectInfo.Started() { + // Until we know both a good and a bad commit, git hasn't checked out + // anything for the user to test, and the user may be checking out + // branches to find the commits to mark. Show the log of what's checked + // out, as usual. + if !bisectInfo.Bisecting() { return "HEAD", bisectInfo } // need to see if our bisect's current commit is reachable from our 'new' ref. - if bisectInfo.Bisecting() && !env.git.Bisect.ReachableFromStart(bisectInfo) { + if !env.git.Bisect.ReachableFromStart(bisectInfo) { return bisectInfo.GetNewHash(), bisectInfo } diff --git a/pkg/integration/tests/bisect/check_out_branch_before_bisecting.go b/pkg/integration/tests/bisect/check_out_branch_before_bisecting.go index b9e7d2bbf..6acfc7feb 100644 --- a/pkg/integration/tests/bisect/check_out_branch_before_bisecting.go +++ b/pkg/integration/tests/bisect/check_out_branch_before_bisecting.go @@ -43,7 +43,6 @@ var CheckOutBranchBeforeBisecting = NewIntegrationTest(NewIntegrationTestArgs{ ) t.Views().Commits(). - /* EXPECTED: Lines( Contains("CI commit-06"), Contains("CI commit-05"), @@ -52,11 +51,5 @@ var CheckOutBranchBeforeBisecting = NewIntegrationTest(NewIntegrationTestArgs{ Contains("CI commit-02"), Contains("CI commit-01"), ) - ACTUAL: */ - Lines( - Contains("CI commit-03").Contains("<-- good"), - Contains("CI commit-02"), - Contains("CI commit-01"), - ) }, }) From b2e9d2a3481bc608f3245720fffccd80f4410875 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 21:06:00 +0100 Subject: [PATCH 08/26] Unify the code that loads all commits when scrolling near the end The commits and the sub-commits views had identical copies of it. A later commit changes when it loads all commits, so make it one function first. Co-Authored-By: Claude Opus 5.5 --- .../controllers/local_commits_controller.go | 21 ++++++++++++++----- pkg/gui/controllers/sub_commits_controller.go | 6 +----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index b5db039d8..bfd54decb 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -21,6 +21,21 @@ import ( // after selecting the 200th commit, we'll load in all the rest const COMMIT_THRESHOLD = 200 +type canLoadAllCommits interface { + GetSelectedLineIdx() int + GetLimitCommits() bool + SetLimitCommits(value bool) +} + +// If we loaded only the first commits of a list, and the selection gets close to +// the end of them, load all of them. +func loadAllCommitsIfSelectionIsNearEnd(c *ControllerCommon, context canLoadAllCommits, scope types.RefreshableView) { + if context.GetSelectedLineIdx() > COMMIT_THRESHOLD && context.GetLimitCommits() { + context.SetLimitCommits(false) + c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{scope}}) + } +} + // How long a commit move may take before the drop indicator switches to a // "moving commits here" spinner; quick moves stay free of flicker. const commitDragMovingIndicatorDelay = 200 * time.Millisecond @@ -1807,11 +1822,7 @@ func (self *LocalCommitsController) handleOpenLogMenu() error { func (self *LocalCommitsController) GetOnFocus() func(types.OnFocusOpts) { return func(types.OnFocusOpts) { - context := self.context() - if context.GetSelectedLineIdx() > COMMIT_THRESHOLD && context.GetLimitCommits() { - context.SetLimitCommits(false) - self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}}) - } + loadAllCommitsIfSelectionIsNearEnd(self.c, self.context(), types.COMMITS) } } diff --git a/pkg/gui/controllers/sub_commits_controller.go b/pkg/gui/controllers/sub_commits_controller.go index 7f7a163c9..dca7f5af8 100644 --- a/pkg/gui/controllers/sub_commits_controller.go +++ b/pkg/gui/controllers/sub_commits_controller.go @@ -64,10 +64,6 @@ func (self *SubCommitsController) GetOnRenderToMain() func() { func (self *SubCommitsController) GetOnFocus() func(types.OnFocusOpts) { return func(types.OnFocusOpts) { - context := self.context() - if context.GetSelectedLineIdx() > COMMIT_THRESHOLD && context.GetLimitCommits() { - context.SetLimitCommits(false) - self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUB_COMMITS}}) - } + loadAllCommitsIfSelectionIsNearEnd(self.c, self.context(), types.SUB_COMMITS) } } From 0d41e696aca66c084f6ea240440bc37949c8ba3c Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 21:06:57 +0100 Subject: [PATCH 09/26] Pass the number of commits to load to the commit loader The commit loader took a flag for whether to limit the number of commits it loads, and the limit of 300 was hard-coded in it. A later commit needs to load more than that while bisecting, so let the caller pass the number. Co-Authored-By: Claude Opus 5.5 --- pkg/commands/git_commands/commit_loader.go | 4 ++-- pkg/gui/controllers/helpers/refresh_helper.go | 8 ++++++-- pkg/gui/controllers/helpers/sub_commits_helper.go | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index 381dd641e..987f2394e 100644 --- a/pkg/commands/git_commands/commit_loader.go +++ b/pkg/commands/git_commands/commit_loader.go @@ -56,7 +56,7 @@ func NewCommitLoader( } type GetCommitsOptions struct { - Limit bool + Limit int // the maximum number of commits to load, or 0 to load all of them FilterPath string FilterAuthor string IncludeRebaseCommits bool @@ -611,7 +611,7 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) *oscommands.CmdObj { Arg(prettyFormat). Arg("--abbrev=40"). ArgIf(opts.FilterAuthor != "", "--author="+opts.FilterAuthor). - ArgIf(opts.Limit, "-300"). + ArgIf(opts.Limit > 0, fmt.Sprintf("-%d", opts.Limit)). ArgIf(opts.FilterPath != "", "--follow", "--name-status"). Arg("--no-show-signature"). ArgIf(opts.RefToShowDivergenceFrom != "", "--left-right"). diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index c367fd80b..f6fc539b2 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -758,6 +758,10 @@ func (self *RefreshHelper) refreshReflogAndBranches(capturedReflog capturedReflo return nil } +// The number of commits that the commits and sub-commits views load at first, +// to keep things fast. They load the rest when the user scrolls near the end. +const commitLimit = 300 + // capturedCommitState holds everything the commits refresh reads from the // model, contexts, and modes. It is gathered on the UI thread (see // captureCommitsState) before the git work is dispatched to a worker, so the @@ -852,7 +856,7 @@ func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, refName, bisectInfo := self.refForLog(env) commits, err := env.git.Loaders.CommitLoader.GetCommits( git_commands.GetCommitsOptions{ - Limit: captured.limitCommits, + Limit: lo.Ternary(captured.limitCommits, commitLimit, 0), FilterPath: captured.filterPath, FilterAuthor: captured.filterAuthor, IncludeRebaseCommits: true, @@ -1073,7 +1077,7 @@ func (self *RefreshHelper) refreshSubCommitsWithLimit(captured capturedSubCommit commits, err := env.git.Loaders.CommitLoader.GetCommits( git_commands.GetCommitsOptions{ - Limit: captured.limitCommits, + Limit: lo.Ternary(captured.limitCommits, commitLimit, 0), FilterPath: captured.filterPath, FilterAuthor: captured.filterAuthor, IncludeRebaseCommits: false, diff --git a/pkg/gui/controllers/helpers/sub_commits_helper.go b/pkg/gui/controllers/helpers/sub_commits_helper.go index 09f32d1a9..e3d02dd8c 100644 --- a/pkg/gui/controllers/helpers/sub_commits_helper.go +++ b/pkg/gui/controllers/helpers/sub_commits_helper.go @@ -34,7 +34,7 @@ type ViewSubCommitsOpts struct { func (self *SubCommitsHelper) ViewSubCommits(opts ViewSubCommitsOpts) error { commits, err := self.c.Git().Loaders.CommitLoader.GetCommits( git_commands.GetCommitsOptions{ - Limit: true, + Limit: commitLimit, FilterPath: self.c.Modes().Filtering.GetPath(), FilterAuthor: self.c.Modes().Filtering.GetAuthor(), IncludeRebaseCommits: false, From ee07abe5083e0a1c5b0f4251b5fbcbf7efc018bc Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 21:07:49 +0100 Subject: [PATCH 10/26] Load all commits when the selection is near the end of the loaded ones The commits and sub-commits views load the first 300 commits, and load all of them once the user selects a commit beyond the 200th. A later commit loads more than 300 commits while bisecting, so that the commit to test is among them. If it is beyond the 200th, it would cause all commits to be loaded as soon as it gets selected. Remember how many commits the views were loaded with, and load all of them only when the selection gets within 100 commits of that number. For the views loaded with 300 commits, nothing changes. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/context/local_commits_context.go | 12 ++++++++++++ pkg/gui/context/sub_commits_context.go | 15 +++++++++++++-- pkg/gui/controllers/helpers/refresh_helper.go | 8 ++++++-- pkg/gui/controllers/helpers/sub_commits_helper.go | 1 + pkg/gui/controllers/local_commits_controller.go | 9 ++++++--- 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/pkg/gui/context/local_commits_context.go b/pkg/gui/context/local_commits_context.go index 0f09c859c..e9faf3911 100644 --- a/pkg/gui/context/local_commits_context.go +++ b/pkg/gui/context/local_commits_context.go @@ -343,6 +343,10 @@ type LocalCommitsViewModel struct { // commits refresh reads it on the UI thread to decide how many commits to load. limitCommits atomic.Bool + // The limit that the commits in the model were loaded with, or 0 if they + // were loaded without one. + loadedCommitLimit int + // If this is true we'll use git log --all when fetching the commits. showWholeGitGraph bool } @@ -431,6 +435,14 @@ func (self *LocalCommitsViewModel) GetLimitCommits() bool { return self.limitCommits.Load() } +func (self *LocalCommitsViewModel) SetLoadedCommitLimit(value int) { + self.loadedCommitLimit = value +} + +func (self *LocalCommitsViewModel) GetLoadedCommitLimit() int { + return self.loadedCommitLimit +} + func (self *LocalCommitsViewModel) SetShowWholeGitGraph(value bool) { self.showWholeGitGraph = value } diff --git a/pkg/gui/context/sub_commits_context.go b/pkg/gui/context/sub_commits_context.go index e99b5d281..73d3022b5 100644 --- a/pkg/gui/context/sub_commits_context.go +++ b/pkg/gui/context/sub_commits_context.go @@ -174,8 +174,11 @@ type SubCommitsViewModel struct { refToShowDivergenceFrom string *ListViewModel[*models.Commit] - limitCommits bool - showBranchHeads bool + limitCommits bool + // The limit that the commits in the model were loaded with, or 0 if they + // were loaded without one. + loadedCommitLimit int + showBranchHeads bool } func (self *SubCommitsViewModel) SetRef(ref models.Ref) { @@ -239,6 +242,14 @@ func (self *SubCommitsContext) GetLimitCommits() bool { return self.limitCommits } +func (self *SubCommitsContext) SetLoadedCommitLimit(value int) { + self.loadedCommitLimit = value +} + +func (self *SubCommitsContext) GetLoadedCommitLimit() int { + return self.loadedCommitLimit +} + func (self *SubCommitsContext) GetDiffTerminals() []string { itemId := self.GetSelectedItemId() diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index f6fc539b2..c67e79f0c 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -854,9 +854,10 @@ func (self *RefreshHelper) determineCheckedOutRef(env refreshEnv) models.Ref { func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, commitSelection types.CommitSelectionBehavior, env refreshEnv) error { checkedOutRef := self.determineCheckedOutRef(env) refName, bisectInfo := self.refForLog(env) + limit := lo.Ternary(captured.limitCommits, commitLimit, 0) commits, err := env.git.Loaders.CommitLoader.GetCommits( git_commands.GetCommitsOptions{ - Limit: lo.Ternary(captured.limitCommits, commitLimit, 0), + Limit: limit, FilterPath: captured.filterPath, FilterAuthor: captured.filterAuthor, IncludeRebaseCommits: true, @@ -886,6 +887,7 @@ func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, self.c.Model().BisectInfo = bisectInfo self.c.Model().Commits = commits + self.c.Contexts().LocalCommits.SetLoadedCommitLimit(limit) self.c.Model().CommitsWereFilteredAtLastRefresh = captured.filterPath != "" || captured.filterAuthor != "" self.RefreshAuthors(commits) self.c.Model().WorkingTreeStateAtLastCommitRefresh = workingTreeState @@ -1075,9 +1077,10 @@ func (self *RefreshHelper) refreshSubCommitsWithLimit(captured capturedSubCommit return nil } + limit := lo.Ternary(captured.limitCommits, commitLimit, 0) commits, err := env.git.Loaders.CommitLoader.GetCommits( git_commands.GetCommitsOptions{ - Limit: lo.Ternary(captured.limitCommits, commitLimit, 0), + Limit: limit, FilterPath: captured.filterPath, FilterAuthor: captured.filterAuthor, IncludeRebaseCommits: false, @@ -1093,6 +1096,7 @@ func (self *RefreshHelper) refreshSubCommitsWithLimit(captured capturedSubCommit } self.onUIThreadUnlessRepoChanged(env, func() { self.c.Model().SubCommits = commits + self.c.Contexts().SubCommits.SetLoadedCommitLimit(limit) self.RefreshAuthors(commits) }) diff --git a/pkg/gui/controllers/helpers/sub_commits_helper.go b/pkg/gui/controllers/helpers/sub_commits_helper.go index e3d02dd8c..23bb03f55 100644 --- a/pkg/gui/controllers/helpers/sub_commits_helper.go +++ b/pkg/gui/controllers/helpers/sub_commits_helper.go @@ -60,6 +60,7 @@ func (self *SubCommitsHelper) ViewSubCommits(opts ViewSubCommitsOpts) error { subCommitsContext.SetRef(opts.Ref) subCommitsContext.SetRefToShowDivergenceFrom(opts.RefToShowDivergenceFrom) subCommitsContext.SetLimitCommits(true) + subCommitsContext.SetLoadedCommitLimit(commitLimit) subCommitsContext.SetShowBranchHeads(opts.ShowBranchHeads) subCommitsContext.ClearSearchString() subCommitsContext.GetView().ClearSearch() diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index bfd54decb..1489e5e71 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -18,19 +18,22 @@ import ( "github.com/stefanhaller/git-todo-parser/todo" ) -// after selecting the 200th commit, we'll load in all the rest -const COMMIT_THRESHOLD = 200 +// If the selection gets this close to the end of the commits that we loaded, +// we load all the rest +const loadAllCommitsMargin = 100 type canLoadAllCommits interface { GetSelectedLineIdx() int GetLimitCommits() bool SetLimitCommits(value bool) + GetLoadedCommitLimit() int } // If we loaded only the first commits of a list, and the selection gets close to // the end of them, load all of them. func loadAllCommitsIfSelectionIsNearEnd(c *ControllerCommon, context canLoadAllCommits, scope types.RefreshableView) { - if context.GetSelectedLineIdx() > COMMIT_THRESHOLD && context.GetLimitCommits() { + limit := context.GetLoadedCommitLimit() + if context.GetLimitCommits() && limit > 0 && context.GetSelectedLineIdx() > limit-loadAllCommitsMargin { context.SetLimitCommits(false) c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{scope}}) } From 990913dd6393af0c586e23fd3ecabc97ed41795e Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 21:09:44 +0100 Subject: [PATCH 11/26] Add a test showing that a current bisect commit far down isn't selected The commits view loads the first 300 commits only. If the range to bisect is longer than about 600 commits, the commit that git wants the user to test is further down than that. It isn't loaded, so we can't select it. Co-Authored-By: Claude Opus 5.5 --- .../select_current_commit_in_long_range.go | 31 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 32 insertions(+) create mode 100644 pkg/integration/tests/bisect/select_current_commit_in_long_range.go diff --git a/pkg/integration/tests/bisect/select_current_commit_in_long_range.go b/pkg/integration/tests/bisect/select_current_commit_in_long_range.go new file mode 100644 index 000000000..e3ad8aeba --- /dev/null +++ b/pkg/integration/tests/bisect/select_current_commit_in_long_range.go @@ -0,0 +1,31 @@ +package bisect + +import ( + "fmt" + + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SelectCurrentCommitInLongRange = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Select the current bisect commit when it is further down than the commits that we load at first", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + for i := range 700 { + shell.EmptyCommit(fmt.Sprintf("commit %03d", i+1)) + } + shell.StartBisect("HEAD", "HEAD~699") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + /* EXPECTED: + SelectedLine(Contains("<-- current")) + ACTUAL: */ + SelectedLine(Contains("commit 700")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 15aa27ea5..decdd2b73 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -40,6 +40,7 @@ var tests = []*components.IntegrationTest{ bisect.ChooseTerms, bisect.FromOtherBranch, bisect.SelectCurrentCommit, + bisect.SelectCurrentCommitInLongRange, bisect.Skip, branch.CheckoutAutostash, branch.CheckoutByName, From 08065f02945e4304226202268a02823e5ba66582 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 21:10:31 +0100 Subject: [PATCH 12/26] Load the commits down to the current bisect commit The commits view loads the first 300 commits only. If the range to bisect is longer than about 600 commits, the commit that git wants the user to test is further down than that, so it isn't shown, and we can't select it. While bisecting, count the commits in the log above the current commit, and load that many more than usual. Co-Authored-By: Claude Opus 5.5 --- pkg/commands/git_commands/bisect.go | 18 +++++++++++++++ pkg/gui/controllers/helpers/refresh_helper.go | 23 ++++++++++++++++++- .../select_current_commit_in_long_range.go | 3 --- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/pkg/commands/git_commands/bisect.go b/pkg/commands/git_commands/bisect.go index d3dff54d4..e554af117 100644 --- a/pkg/commands/git_commands/bisect.go +++ b/pkg/commands/git_commands/bisect.go @@ -3,6 +3,7 @@ package git_commands import ( "os" "path/filepath" + "strconv" "strings" ) @@ -192,3 +193,20 @@ func (self *BisectCommands) ReachableFromStart(bisectInfo *BisectInfo) bool { return err == nil } + +// Returns the number of commits that are reachable from logRef but not from +// the given commit. In a log of logRef, parents come after their children +// (unless the log uses git's default order and commit dates are skewed), so +// the commit is at most this many commits down from the top. +func (self *BisectCommands) CountCommitsAbove(hash string, logRef string) (int, error) { + cmdArgs := NewGitCmd("rev-list"). + Arg("--count", hash+".."+logRef). + ToArgv() + + output, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput() + if err != nil { + return 0, err + } + + return strconv.Atoi(strings.TrimSpace(output)) +} diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index c67e79f0c..aa1906a36 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -854,7 +854,7 @@ func (self *RefreshHelper) determineCheckedOutRef(env refreshEnv) models.Ref { func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, commitSelection types.CommitSelectionBehavior, env refreshEnv) error { checkedOutRef := self.determineCheckedOutRef(env) refName, bisectInfo := self.refForLog(env) - limit := lo.Ternary(captured.limitCommits, commitLimit, 0) + limit := self.commitLimitForLog(captured.limitCommits, refName, bisectInfo, env) commits, err := env.git.Loaders.CommitLoader.GetCommits( git_commands.GetCommitsOptions{ Limit: limit, @@ -1777,6 +1777,27 @@ func (self *RefreshHelper) refForLog(env refreshEnv) (string, *git_commands.Bise return bisectInfo.GetStartHash(), bisectInfo } +// commitLimitForLog returns the number of commits to load for the commits view, +// or 0 to load all of them. +func (self *RefreshHelper) commitLimitForLog(limitCommits bool, refName string, bisectInfo *git_commands.BisectInfo, env refreshEnv) int { + if !limitCommits { + return 0 + } + + if hash := bisectCommitToSelect(bisectInfo); hash != "" { + // Load the commit that the user needs to look at, and as many commits + // after it as we load from the top otherwise. This way we can select it + // without having to load all commits. + count, err := env.git.Bisect.CountCommitsAbove(hash, refName) + if err == nil { + return count + commitLimit + } + self.c.Log.Warnf("Failed to count the commits above the bisect commit to select: %v", err) + } + + return commitLimit +} + func (self *RefreshHelper) refreshView(context types.Context, env refreshEnv) { // refreshView is called from the worker goroutine that drives async // refreshes, so bounce to the UI thread before mutating view content. Guard diff --git a/pkg/integration/tests/bisect/select_current_commit_in_long_range.go b/pkg/integration/tests/bisect/select_current_commit_in_long_range.go index e3ad8aeba..09794c59f 100644 --- a/pkg/integration/tests/bisect/select_current_commit_in_long_range.go +++ b/pkg/integration/tests/bisect/select_current_commit_in_long_range.go @@ -23,9 +23,6 @@ var SelectCurrentCommitInLongRange = NewIntegrationTest(NewIntegrationTestArgs{ Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). - /* EXPECTED: SelectedLine(Contains("<-- current")) - ACTUAL: */ - SelectedLine(Contains("commit 700")) }, }) From 027a5babebc0435f04888d2d8bc8278abf56393a Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 21:12:07 +0100 Subject: [PATCH 13/26] Add a test showing that the bisect menu mislabels the selected commit After marking the first commit as good or bad, the bisect menu acts on the selected commit until git knows both a good and a bad commit. Its entries call that commit the "current commit" though, as if it was the commit that git wants the user to test. Co-Authored-By: Claude Opus 5.5 --- pkg/integration/tests/bisect/skip.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg/integration/tests/bisect/skip.go b/pkg/integration/tests/bisect/skip.go index 7c9ef4aea..d3f92f744 100644 --- a/pkg/integration/tests/bisect/skip.go +++ b/pkg/integration/tests/bisect/skip.go @@ -27,7 +27,26 @@ var Skip = NewIntegrationTest(NewIntegrationTestArgs{ NavigateToLine(Contains("commit-01")). Press(keys.Commits.ViewBisectOptions). Tap(func() { - t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as good`)).Confirm() + t.ExpectPopup().Menu().Title(Equals("Bisect")). + // There's no current commit yet, so the entries act on the + // selected commit: + /* EXPECTED: + Lines( + Contains("b Mark commit").Contains("as bad"), + Contains("g Mark commit").Contains("as good"), + Contains("s Skip commit"), + Contains("r Reset bisect"), + Contains("Cancel"), + ). + ACTUAL: */ + Lines( + Contains("b Mark current commit").Contains("as bad"), + Contains("g Mark current commit").Contains("as good"), + Contains("s Skip current commit"), + Contains("r Reset bisect"), + Contains("Cancel"), + ). + Select(MatchesRegexp(`Mark .* as good`)).Confirm() t.Views().Information().Content(Contains("Bisecting")) }). Lines( From 9761cec61abd9d3a20201ae8a4910adc97d509b0 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 21:13:32 +0100 Subject: [PATCH 14/26] Split the bisect menu for before and while bisecting One function built the menu both for when git still waits for a good or a bad commit, and for while bisecting. Its entries act on the selected commit in the first case, and on the commit that git wants the user to test in the second case. Several conditions in the function picked between the two. The next commits change the first menu only, so make it a function of its own. Extract the menu entries that both menus have, so that they don't get duplicated. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/controllers/bisect_controller.go | 176 ++++++++++++----------- 1 file changed, 94 insertions(+), 82 deletions(-) diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index b6c82d49c..dc77423a4 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -8,7 +8,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" - "github.com/samber/lo" ) type BisectController struct { @@ -51,95 +50,66 @@ func (self *BisectController) openMenu(commit *models.Commit) error { // no shame in getting this directly rather than using the cached value // given how cheap it is to obtain info := self.c.Git().Bisect.GetInfo() - if info.Started() { - return self.openMidBisectMenu(info, commit) + if !info.Started() { + return self.openStartBisectMenu(info, commit) } - return self.openStartBisectMenu(info, commit) + if info.GetCurrentHash() == "" { + return self.openMenuBeforeBisecting(info, commit) + } + return self.openMidBisectMenu(info, commit) } +// The menu for when a bisect has started, but git doesn't know both a good and +// a bad commit yet. Its entries act on the selected commit. +func (self *BisectController) openMenuBeforeBisecting(info *git_commands.BisectInfo, commit *models.Commit) error { + disabledReason := self.require(self.singleItemSelected())() + + return self.c.Menu(types.CreateMenuOptions{ + Title: self.c.Tr.Bisect.BisectMenuTitle, + Items: []*types.MenuItem{ + self.markMenuItem( + fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortHash(), info.NewTerm()), + commit.Hash(), info.NewTerm(), disabledReason, 'b'), + self.markMenuItem( + fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortHash(), info.OldTerm()), + commit.Hash(), info.OldTerm(), disabledReason, 'g'), + self.skipMenuItem( + fmt.Sprintf(self.c.Tr.Bisect.SkipCurrent, commit.ShortHash()), + commit.Hash(), types.KeepCommitSelectionByHash, disabledReason, 's'), + self.resetMenuItem(), + }, + }) +} + +// The menu for while bisecting. Its entries act on the commit that git wants the +// user to test, except for the one that skips the selected commit. func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, commit *models.Commit) error { - // If we have a current hash already, then we always want to use that one. If - // not, we're still picking the initial commits before we really start, so - // use the selected commit in that case. - - bisecting := info.GetCurrentHash() != "" - hashToMark := lo.Ternary(bisecting, info.GetCurrentHash(), commit.Hash()) - shortHashToMark := utils.ShortHash(hashToMark) - - // For marking a commit as bad, when we're not already bisecting, we require - // a single item selected, but once we are bisecting, it doesn't matter because - // the action applies to the HEAD commit rather than the selected commit. - var singleItemIfNotBisecting *types.DisabledReason - if !bisecting { - singleItemIfNotBisecting = self.require(self.singleItemSelected())() - } + currentHash := info.GetCurrentHash() + shortCurrentHash := utils.ShortHash(currentHash) menuItems := []*types.MenuItem{ - { - Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, shortHashToMark, info.NewTerm()), - OnPress: func() error { - self.c.LogAction(self.c.Tr.Actions.BisectMark) - if err := self.c.Git().Bisect.Mark(hashToMark, info.NewTerm()); err != nil { - return err - } - - return self.afterMark(types.KeepCommitSelectionByHash) - }, - DisabledReason: singleItemIfNotBisecting, - Keys: menuKey('b'), - }, - { - Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, shortHashToMark, info.OldTerm()), - OnPress: func() error { - self.c.LogAction(self.c.Tr.Actions.BisectMark) - if err := self.c.Git().Bisect.Mark(hashToMark, info.OldTerm()); err != nil { - return err - } - - return self.afterMark(types.KeepCommitSelectionByHash) - }, - DisabledReason: singleItemIfNotBisecting, - Keys: menuKey('g'), - }, - { - Label: fmt.Sprintf(self.c.Tr.Bisect.SkipCurrent, shortHashToMark), - OnPress: func() error { - self.c.LogAction(self.c.Tr.Actions.BisectSkip) - if err := self.c.Git().Bisect.Skip(hashToMark); err != nil { - return err - } - - return self.afterMark(types.KeepCommitSelectionByHash) - }, - DisabledReason: singleItemIfNotBisecting, - Keys: menuKey('s'), - }, + self.markMenuItem( + fmt.Sprintf(self.c.Tr.Bisect.Mark, shortCurrentHash, info.NewTerm()), + currentHash, info.NewTerm(), nil, 'b'), + self.markMenuItem( + fmt.Sprintf(self.c.Tr.Bisect.Mark, shortCurrentHash, info.OldTerm()), + currentHash, info.OldTerm(), nil, 'g'), + self.skipMenuItem( + fmt.Sprintf(self.c.Tr.Bisect.SkipCurrent, shortCurrentHash), + currentHash, types.KeepCommitSelectionByHash, nil, 's'), } - if info.GetCurrentHash() != "" && info.GetCurrentHash() != commit.Hash() { - menuItems = append(menuItems, lo.ToPtr(types.MenuItem{ - Label: fmt.Sprintf(self.c.Tr.Bisect.SkipSelected, commit.ShortHash()), - OnPress: func() error { - self.c.LogAction(self.c.Tr.Actions.BisectSkip) - if err := self.c.Git().Bisect.Skip(commit.Hash()); err != nil { - return err - } - - // Git may pick a different commit to test now. Keep the skipped - // commit selected anyway, so that the user can go on skipping - // commits near it. - return self.afterMark(types.KeepCommitSelectionIndex) - }, - DisabledReason: self.require(self.singleItemSelected())(), - Keys: menuKey('S'), - })) + if currentHash != commit.Hash() { + menuItems = append(menuItems, self.skipMenuItem( + fmt.Sprintf(self.c.Tr.Bisect.SkipSelected, commit.ShortHash()), + commit.Hash(), + // Git may pick a different commit to test now. Keep the skipped + // commit selected anyway, so that the user can go on skipping + // commits near it. + types.KeepCommitSelectionIndex, + self.require(self.singleItemSelected())(), + 'S')) } - menuItems = append(menuItems, lo.ToPtr(types.MenuItem{ - Label: self.c.Tr.Bisect.ResetOption, - OnPress: func() error { - return self.c.Helpers().Bisect.Reset() - }, - Keys: menuKey('r'), - })) + menuItems = append(menuItems, self.resetMenuItem()) return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.Bisect.BisectMenuTitle, @@ -147,6 +117,48 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c }) } +func (self *BisectController) markMenuItem(label string, hash string, term string, disabledReason *types.DisabledReason, key rune) *types.MenuItem { + return &types.MenuItem{ + Label: label, + OnPress: func() error { + self.c.LogAction(self.c.Tr.Actions.BisectMark) + if err := self.c.Git().Bisect.Mark(hash, term); err != nil { + return err + } + + return self.afterMark(types.KeepCommitSelectionByHash) + }, + DisabledReason: disabledReason, + Keys: menuKey(key), + } +} + +func (self *BisectController) skipMenuItem(label string, hash string, commitSelection types.CommitSelectionBehavior, disabledReason *types.DisabledReason, key rune) *types.MenuItem { + return &types.MenuItem{ + Label: label, + OnPress: func() error { + self.c.LogAction(self.c.Tr.Actions.BisectSkip) + if err := self.c.Git().Bisect.Skip(hash); err != nil { + return err + } + + return self.afterMark(commitSelection) + }, + DisabledReason: disabledReason, + Keys: menuKey(key), + } +} + +func (self *BisectController) resetMenuItem() *types.MenuItem { + return &types.MenuItem{ + Label: self.c.Tr.Bisect.ResetOption, + OnPress: func() error { + return self.c.Helpers().Bisect.Reset() + }, + Keys: menuKey('r'), + } +} + func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, commit *models.Commit) error { return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.Bisect.BisectMenuTitle, From eef08f04ecadc57e23ee935689f09317ab42f055 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 21:14:47 +0100 Subject: [PATCH 15/26] Don't call the selected commit "current" before bisecting starts After marking the first commit as good or bad, the bisect menu's entries act on the selected commit until git knows both a good and a bad commit. They called it the "current commit" though, as if it was the commit that git wants the user to test. Call it "commit " instead. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/controllers/bisect_controller.go | 16 +++++++++------- pkg/i18n/english.go | 6 ++++++ pkg/integration/tests/bisect/skip.go | 9 --------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index dc77423a4..b44177536 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -63,18 +63,20 @@ func (self *BisectController) openMenu(commit *models.Commit) error { // a bad commit yet. Its entries act on the selected commit. func (self *BisectController) openMenuBeforeBisecting(info *git_commands.BisectInfo, commit *models.Commit) error { disabledReason := self.require(self.singleItemSelected())() + ref := utils.ResolvePlaceholderString(self.c.Tr.Bisect.CommitRef, + map[string]string{"hash": commit.ShortHash()}) + markLabel := func(term string) string { + return utils.ResolvePlaceholderString(self.c.Tr.Bisect.MarkRef, + map[string]string{"ref": ref, "term": term}) + } return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.Bisect.BisectMenuTitle, Items: []*types.MenuItem{ - self.markMenuItem( - fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortHash(), info.NewTerm()), - commit.Hash(), info.NewTerm(), disabledReason, 'b'), - self.markMenuItem( - fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortHash(), info.OldTerm()), - commit.Hash(), info.OldTerm(), disabledReason, 'g'), + self.markMenuItem(markLabel(info.NewTerm()), commit.Hash(), info.NewTerm(), disabledReason, 'b'), + self.markMenuItem(markLabel(info.OldTerm()), commit.Hash(), info.OldTerm(), disabledReason, 'g'), self.skipMenuItem( - fmt.Sprintf(self.c.Tr.Bisect.SkipCurrent, commit.ShortHash()), + utils.ResolvePlaceholderString(self.c.Tr.Bisect.SkipRef, map[string]string{"ref": ref}), commit.Hash(), types.KeepCommitSelectionByHash, disabledReason, 's'), self.resetMenuItem(), }, diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index b71d084a6..c4dd71efd 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -1048,8 +1048,11 @@ type Bisect struct { NewTermPrompt string BisectMenuTitle string Mark string + MarkRef string SkipCurrent string SkipSelected string + SkipRef string + CommitRef string CompleteTitle string CompletePrompt string CompletePromptIndeterminate string @@ -2374,6 +2377,9 @@ func EnglishTranslationSet() *TranslationSet { MarkStart: "Mark %s as %s (start bisect)", SkipCurrent: "Skip current commit (%s)", SkipSelected: "Skip selected commit (%s)", + MarkRef: "Mark {{.ref}} as {{.term}}", + SkipRef: "Skip {{.ref}}", + CommitRef: "commit {{.hash}}", ResetTitle: "Reset 'git bisect'", ResetPrompt: "Are you sure you want to reset 'git bisect'?", ResetOption: "Reset bisect", diff --git a/pkg/integration/tests/bisect/skip.go b/pkg/integration/tests/bisect/skip.go index d3f92f744..50abe342b 100644 --- a/pkg/integration/tests/bisect/skip.go +++ b/pkg/integration/tests/bisect/skip.go @@ -30,7 +30,6 @@ var Skip = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Menu().Title(Equals("Bisect")). // There's no current commit yet, so the entries act on the // selected commit: - /* EXPECTED: Lines( Contains("b Mark commit").Contains("as bad"), Contains("g Mark commit").Contains("as good"), @@ -38,14 +37,6 @@ var Skip = NewIntegrationTest(NewIntegrationTestArgs{ Contains("r Reset bisect"), Contains("Cancel"), ). - ACTUAL: */ - Lines( - Contains("b Mark current commit").Contains("as bad"), - Contains("g Mark current commit").Contains("as good"), - Contains("s Skip current commit"), - Contains("r Reset bisect"), - Contains("Cancel"), - ). Select(MatchesRegexp(`Mark .* as good`)).Confirm() t.Views().Information().Content(Contains("Bisecting")) }). From 308a11f84d39c16930db290199f18bf0fc44d431 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 21:16:52 +0100 Subject: [PATCH 16/26] Let the bisect controller work with any context that has a selected ref It worked with the commits of the local commits context only. The next commit offers the bisect menu in other views too, such as branches and tags, so let it take any context and act on its selected ref. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/controllers.go | 2 +- pkg/gui/controllers/bisect_controller.go | 73 ++++++++++++++---------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index 39d03ef9d..a580983d3 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -146,7 +146,7 @@ func (gui *Gui) resetHelpersAndControllers() { submodulesController := controllers.NewSubmodulesController(common) - bisectController := controllers.NewBisectController(common) + bisectController := controllers.NewBisectController(common, gui.State.Contexts.LocalCommits) commitMessageController := controllers.NewCommitMessageController( common, diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index b44177536..b76f737e7 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -10,9 +10,14 @@ import ( "github.com/jesseduffield/lazygit/pkg/utils" ) +type CanBisect interface { + types.IListContext + GetSelectedRef() models.Ref +} + type BisectController struct { baseController - *ListControllerTrait[*models.Commit] + *ListControllerTrait[models.Ref] c *ControllerCommon } @@ -20,15 +25,18 @@ var _ types.IController = &BisectController{} func NewBisectController( c *ControllerCommon, + context CanBisect, ) *BisectController { return &BisectController{ baseController: baseController{}, c: c, ListControllerTrait: NewListControllerTrait( c, - c.Contexts().LocalCommits, - c.Contexts().LocalCommits.GetSelected, - c.Contexts().LocalCommits.GetSelectedItems, + context, + context.GetSelectedRef, + func() ([]models.Ref, int, int) { + panic("Not implemented") + }, ), } } @@ -46,38 +54,37 @@ func (self *BisectController) GetKeybindings(opts types.KeybindingsOpts) []*type return bindings } -func (self *BisectController) openMenu(commit *models.Commit) error { +func (self *BisectController) openMenu(ref models.Ref) error { // no shame in getting this directly rather than using the cached value // given how cheap it is to obtain info := self.c.Git().Bisect.GetInfo() if !info.Started() { - return self.openStartBisectMenu(info, commit) + return self.openStartBisectMenu(info, ref) } if info.GetCurrentHash() == "" { - return self.openMenuBeforeBisecting(info, commit) + return self.openMenuBeforeBisecting(info, ref) } - return self.openMidBisectMenu(info, commit) + return self.openMidBisectMenu(info, ref) } // The menu for when a bisect has started, but git doesn't know both a good and -// a bad commit yet. Its entries act on the selected commit. -func (self *BisectController) openMenuBeforeBisecting(info *git_commands.BisectInfo, commit *models.Commit) error { +// a bad commit yet. Its entries act on the selected item. +func (self *BisectController) openMenuBeforeBisecting(info *git_commands.BisectInfo, ref models.Ref) error { disabledReason := self.require(self.singleItemSelected())() - ref := utils.ResolvePlaceholderString(self.c.Tr.Bisect.CommitRef, - map[string]string{"hash": commit.ShortHash()}) + refDescription := self.describeRef(ref) markLabel := func(term string) string { return utils.ResolvePlaceholderString(self.c.Tr.Bisect.MarkRef, - map[string]string{"ref": ref, "term": term}) + map[string]string{"ref": refDescription, "term": term}) } return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.Bisect.BisectMenuTitle, Items: []*types.MenuItem{ - self.markMenuItem(markLabel(info.NewTerm()), commit.Hash(), info.NewTerm(), disabledReason, 'b'), - self.markMenuItem(markLabel(info.OldTerm()), commit.Hash(), info.OldTerm(), disabledReason, 'g'), + self.markMenuItem(markLabel(info.NewTerm()), ref.FullRefName(), info.NewTerm(), disabledReason, 'b'), + self.markMenuItem(markLabel(info.OldTerm()), ref.FullRefName(), info.OldTerm(), disabledReason, 'g'), self.skipMenuItem( - utils.ResolvePlaceholderString(self.c.Tr.Bisect.SkipRef, map[string]string{"ref": ref}), - commit.Hash(), types.KeepCommitSelectionByHash, disabledReason, 's'), + utils.ResolvePlaceholderString(self.c.Tr.Bisect.SkipRef, map[string]string{"ref": refDescription}), + ref.FullRefName(), types.KeepCommitSelectionByHash, disabledReason, 's'), self.resetMenuItem(), }, }) @@ -85,7 +92,7 @@ func (self *BisectController) openMenuBeforeBisecting(info *git_commands.BisectI // The menu for while bisecting. Its entries act on the commit that git wants the // user to test, except for the one that skips the selected commit. -func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, commit *models.Commit) error { +func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, ref models.Ref) error { currentHash := info.GetCurrentHash() shortCurrentHash := utils.ShortHash(currentHash) @@ -100,10 +107,10 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c fmt.Sprintf(self.c.Tr.Bisect.SkipCurrent, shortCurrentHash), currentHash, types.KeepCommitSelectionByHash, nil, 's'), } - if currentHash != commit.Hash() { + if currentHash != ref.FullRefName() { menuItems = append(menuItems, self.skipMenuItem( - fmt.Sprintf(self.c.Tr.Bisect.SkipSelected, commit.ShortHash()), - commit.Hash(), + fmt.Sprintf(self.c.Tr.Bisect.SkipSelected, utils.ShortHash(ref.FullRefName())), + ref.FullRefName(), // Git may pick a different commit to test now. Keep the skipped // commit selected anyway, so that the user can go on skipping // commits near it. @@ -119,12 +126,18 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c }) } -func (self *BisectController) markMenuItem(label string, hash string, term string, disabledReason *types.DisabledReason, key rune) *types.MenuItem { +// Returns how the bisect menu refers to the given item. +func (self *BisectController) describeRef(ref models.Ref) string { + return utils.ResolvePlaceholderString(self.c.Tr.Bisect.CommitRef, + map[string]string{"hash": utils.ShortHash(ref.FullRefName())}) +} + +func (self *BisectController) markMenuItem(label string, ref string, term string, disabledReason *types.DisabledReason, key rune) *types.MenuItem { return &types.MenuItem{ Label: label, OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.BisectMark) - if err := self.c.Git().Bisect.Mark(hash, term); err != nil { + if err := self.c.Git().Bisect.Mark(ref, term); err != nil { return err } @@ -135,12 +148,12 @@ func (self *BisectController) markMenuItem(label string, hash string, term strin } } -func (self *BisectController) skipMenuItem(label string, hash string, commitSelection types.CommitSelectionBehavior, disabledReason *types.DisabledReason, key rune) *types.MenuItem { +func (self *BisectController) skipMenuItem(label string, ref string, commitSelection types.CommitSelectionBehavior, disabledReason *types.DisabledReason, key rune) *types.MenuItem { return &types.MenuItem{ Label: label, OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.BisectSkip) - if err := self.c.Git().Bisect.Skip(hash); err != nil { + if err := self.c.Git().Bisect.Skip(ref); err != nil { return err } @@ -161,19 +174,19 @@ func (self *BisectController) resetMenuItem() *types.MenuItem { } } -func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, commit *models.Commit) error { +func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, ref models.Ref) error { return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.Bisect.BisectMenuTitle, Items: []*types.MenuItem{ { - Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortHash(), info.NewTerm()), + Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, utils.ShortHash(ref.FullRefName()), info.NewTerm()), OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.StartBisect) if err := self.c.Git().Bisect.Start(); err != nil { return err } - if err := self.c.Git().Bisect.Mark(commit.Hash(), info.NewTerm()); err != nil { + if err := self.c.Git().Bisect.Mark(ref.FullRefName(), info.NewTerm()); err != nil { return err } @@ -184,14 +197,14 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, Keys: menuKey('b'), }, { - Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortHash(), info.OldTerm()), + Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, utils.ShortHash(ref.FullRefName()), info.OldTerm()), OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.StartBisect) if err := self.c.Git().Bisect.Start(); err != nil { return err } - if err := self.c.Git().Bisect.Mark(commit.Hash(), info.OldTerm()); err != nil { + if err := self.c.Git().Bisect.Mark(ref.FullRefName(), info.OldTerm()); err != nil { return err } From e1336f03dd08badb23bb5c9100dbc2b11ec8446a Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 21:22:04 +0100 Subject: [PATCH 17/26] Offer the bisect menu in more views than the commits panel To start a bisect, users often know that one branch or tag is good and another one is bad. The bisect menu was available in the commits panel only, though. To mark the head of another branch, the user had to check it out first, or find its head commit in the commits panel. The commits panel shows only the checked-out branch. Offer the menu in the local branches, remote branches, tags, sub-commits and reflog views too. There it marks the selected item as good or bad, and its entries name the item ("branch 'dev'", "tag 'v1.0'"), so that it's clear what they act on. Once git knows both a good and a bad commit, the bisect continues in the commits panel. It shows the good and bad commits and the one to test next, and its menu acts on that one. So focus the commits panel when a mark in another view gives git the second of the two, and disable the key in the other views from then on. They don't offer skipping either. Name the selected commit "commit " in the commits panel's menu too, so that it reads the same in all views. Co-Authored-By: Claude Opus 5.5 --- docs-master/keybindings/Keybindings_en.md | 5 ++ docs-master/keybindings/Keybindings_ja.md | 5 ++ docs-master/keybindings/Keybindings_ko.md | 5 ++ docs-master/keybindings/Keybindings_nl.md | 5 ++ docs-master/keybindings/Keybindings_pl.md | 5 ++ docs-master/keybindings/Keybindings_pt.md | 5 ++ docs-master/keybindings/Keybindings_ru.md | 5 ++ docs-master/keybindings/Keybindings_zh-CN.md | 5 ++ docs-master/keybindings/Keybindings_zh-TW.md | 5 ++ pkg/gui/controllers.go | 14 +++- pkg/gui/controllers/bisect_controller.go | 81 +++++++++++++++---- pkg/i18n/english.go | 10 ++- .../tests/bisect/start_from_branches.go | 77 ++++++++++++++++++ .../start_from_sub_commits_and_reflog.go | 70 ++++++++++++++++ .../start_from_tags_and_remote_branches.go | 76 +++++++++++++++++ pkg/integration/tests/test_list.go | 3 + 16 files changed, 356 insertions(+), 20 deletions(-) create mode 100644 pkg/integration/tests/bisect/start_from_branches.go create mode 100644 pkg/integration/tests/bisect/start_from_sub_commits_and_reflog.go create mode 100644 pkg/integration/tests/bisect/start_from_tags_and_remote_branches.go diff --git a/docs-master/keybindings/Keybindings_en.md b/docs-master/keybindings/Keybindings_en.md index 992f34dc9..2ceacf114 100644 --- a/docs-master/keybindings/Keybindings_en.md +++ b/docs-master/keybindings/Keybindings_en.md @@ -175,6 +175,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy branch name to clipboard | | +| `` b `` | View bisect options | | | `` i `` | Show git-flow options | | | `` `` | Checkout | Checkout selected item. | | `` n `` | New branch | | @@ -257,6 +258,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | View bisect options | | | `` `` | Checkout | Checkout the selected commit as a detached HEAD. | | `` y `` | Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). | | `` o `` | Open commit in browser | | @@ -287,6 +289,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` s `` | Sort order | | | `` g `` | Reset | View reset options (soft/mixed/hard) for resetting onto selected item. | | `` `` | Open external diff tool (git difftool) | | +| `` b `` | View bisect options | | | `` 0 `` | Focus main view | | | `` `` | View commits | | | `` / `` | Filter the current view by text | | @@ -358,6 +361,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | View bisect options | | | `` `` | Checkout | Checkout the selected commit as a detached HEAD. | | `` y `` | Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). | | `` o `` | Open commit in browser | | @@ -392,6 +396,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy tag to clipboard | | +| `` b `` | View bisect options | | | `` `` | Checkout | Checkout the selected tag as a detached HEAD. | | `` n `` | New tag | Create new tag from current commit. You'll be prompted to enter a tag name and optional description. | | `` w `` | New worktree | | diff --git a/docs-master/keybindings/Keybindings_ja.md b/docs-master/keybindings/Keybindings_ja.md index 2b1e534e4..45079a676 100644 --- a/docs-master/keybindings/Keybindings_ja.md +++ b/docs-master/keybindings/Keybindings_ja.md @@ -134,6 +134,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | bisectオプションを表示 | | | `` `` | チェックアウト(ブランチの切り替え) | 選択したコミットをデタッチドヘッド(特定のブランチに属さない状態)としてチェックアウトします。 | | `` y `` | コミット属性をクリップボードにコピー | コミット属性をクリップボードにコピーします(例:ハッシュ、URL、差分、メッセージ、作者)。 | | `` o `` | ブラウザでコミットを開く | | @@ -218,6 +219,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | タグをクリップボードにコピー | | +| `` b `` | bisectオプションを表示 | | | `` `` | チェックアウト(ブランチの切り替え) | 選択したタグをデタッチドHEADとしてチェックアウトします。 | | `` n `` | 新しいタグを作成 | 現在のコミットから新しいタグを作成します。タグ名とオプションの説明を入力するよう促されます。 | | `` w `` | 新しいワークツリー | | @@ -318,6 +320,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | bisectオプションを表示 | | | `` `` | チェックアウト(ブランチの切り替え) | 選択したコミットをデタッチドヘッド(特定のブランチに属さない状態)としてチェックアウトします。 | | `` y `` | コミット属性をクリップボードにコピー | コミット属性をクリップボードにコピーします(例:ハッシュ、URL、差分、メッセージ、作者)。 | | `` o `` | ブラウザでコミットを開く | | @@ -360,6 +363,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` s `` | 並び順 | | | `` g `` | リセット | 選択した項目へのリセットオプション(ソフト/ミックス/ハード)を表示します。各リセットタイプの詳細は次の通りです:
- ソフトリセット:変更を保持し、ステージされた状態にします
- ミックスリセット:変更を保持し、ステージされていない状態にします
- ハードリセット:すべての変更を破棄します | | `` `` | 外部差分ツールを開く(git difftool) | | +| `` b `` | bisectオプションを表示 | | | `` 0 `` | メインビューにフォーカス | | | `` `` | コミットを表示 | | | `` / `` | 現在のビューをテキストでフィルタリング | | @@ -369,6 +373,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | ブランチ名をクリップボードにコピー | | +| `` b `` | bisectオプションを表示 | | | `` i `` | git-flowオプションを表示 | | | `` `` | チェックアウト(ブランチの切り替え) | 選択した項目をチェックアウトします。 | | `` n `` | 新しいブランチ | | diff --git a/docs-master/keybindings/Keybindings_ko.md b/docs-master/keybindings/Keybindings_ko.md index 34a91e29a..fd3bda2fd 100644 --- a/docs-master/keybindings/Keybindings_ko.md +++ b/docs-master/keybindings/Keybindings_ko.md @@ -65,6 +65,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | Bisect 옵션 보기 | | | `` `` | 체크아웃 | Checkout the selected commit as a detached HEAD. | | `` y `` | 커밋 attribute 복사 | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). | | `` o `` | 브라우저에서 커밋 열기 | | @@ -124,6 +125,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | Bisect 옵션 보기 | | | `` `` | 체크아웃 | Checkout the selected commit as a detached HEAD. | | `` y `` | 커밋 attribute 복사 | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). | | `` o `` | 브라우저에서 커밋 열기 | | @@ -205,6 +207,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | 브랜치명을 클립보드에 복사 | | +| `` b `` | Bisect 옵션 보기 | | | `` i `` | Git-flow 옵션 보기 | | | `` `` | 체크아웃 | Checkout selected item. | | `` n `` | 새 브랜치 생성 | | @@ -283,6 +286,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` s `` | Sort order | | | `` g `` | View reset options | View reset options (soft/mixed/hard) for resetting onto selected item. | | `` `` | Open external diff tool (git difftool) | | +| `` b `` | Bisect 옵션 보기 | | | `` 0 `` | Focus main view | | | `` `` | 커밋 보기 | | | `` / `` | Filter the current view by text | | @@ -361,6 +365,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy tag to clipboard | | +| `` b `` | Bisect 옵션 보기 | | | `` `` | 체크아웃 | Checkout the selected tag as a detached HEAD. | | `` n `` | 태그를 생성 | Create new tag from current commit. You'll be prompted to enter a tag name and optional description. | | `` w `` | New worktree | | diff --git a/docs-master/keybindings/Keybindings_nl.md b/docs-master/keybindings/Keybindings_nl.md index 136cb770c..d72028a04 100644 --- a/docs-master/keybindings/Keybindings_nl.md +++ b/docs-master/keybindings/Keybindings_nl.md @@ -99,6 +99,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Kopieer branch name naar klembord | | +| `` b `` | View bisect options | | | `` i `` | Laat git-flow opties zien | | | `` `` | Uitchecken | Geselecteerd item uitchecken. | | `` n `` | Nieuwe branch | | @@ -257,6 +258,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | View bisect options | | | `` `` | Uitchecken | Check de geselecteerde branch uit als een detached HEAD. | | `` y `` | Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). | | `` o `` | Open commit in browser | | @@ -287,6 +289,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` s `` | Sort order | | | `` g `` | Bekijk reset opties | View reset options (soft/mixed/hard) for resetting onto selected item. | | `` `` | Open externe diff applicatie (git difftool) | | +| `` b `` | View bisect options | | | `` 0 `` | Focus main view | | | `` `` | Bekijk commits | | | `` / `` | Filter the current view by text | | @@ -358,6 +361,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | View bisect options | | | `` `` | Uitchecken | Check de geselecteerde branch uit als een detached HEAD. | | `` y `` | Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). | | `` o `` | Open commit in browser | | @@ -392,6 +396,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy tag to clipboard | | +| `` b `` | View bisect options | | | `` `` | Uitchecken | Geselecteerde tag uitchecken als detached HEAD. | | `` n `` | Creëer tag | Maak een nieuwe tag die naar de huidige commit wijst. Je wordt gevraagd om een tag naam en optionele beschrijving. | | `` w `` | New worktree | | diff --git a/docs-master/keybindings/Keybindings_pl.md b/docs-master/keybindings/Keybindings_pl.md index 02d568b1d..aee57e771 100644 --- a/docs-master/keybindings/Keybindings_pl.md +++ b/docs-master/keybindings/Keybindings_pl.md @@ -135,6 +135,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | Zobacz opcje bisect | | | `` `` | Przełącz | Przełącz wybrany commit jako odłączoną HEAD. | | `` y `` | Kopiuj atrybut commita do schowka | Kopiuj atrybut commita do schowka (np. hash, URL, różnice, wiadomość, autor). | | `` o `` | Otwórz commit w przeglądarce | | @@ -162,6 +163,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Kopiuj nazwę gałęzi do schowka | | +| `` b `` | Zobacz opcje bisect | | | `` i `` | Pokaż opcje git-flow | | | `` `` | Przełącz | Przełącz wybrany element. | | `` n `` | Nowa gałąź | | @@ -337,6 +339,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | Zobacz opcje bisect | | | `` `` | Przełącz | Przełącz wybrany commit jako odłączoną HEAD. | | `` y `` | Kopiuj atrybut commita do schowka | Kopiuj atrybut commita do schowka (np. hash, URL, różnice, wiadomość, autor). | | `` o `` | Otwórz commit w przeglądarce | | @@ -371,6 +374,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Skopiuj tag do schowka | | +| `` b `` | Zobacz opcje bisect | | | `` `` | Przełącz | Przełącz wybrany tag jako odłączoną głowę (detached HEAD). | | `` n `` | Nowy tag | Utwórz nowy tag z bieżącego commita. Zostaniesz poproszony o wprowadzenie nazwy tagu i opcjonalnego opisu. | | `` w `` | Nowe drzewo pracy | | @@ -409,6 +413,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` s `` | Kolejność sortowania | | | `` g `` | Reset | Wyświetl opcje resetu (miękki/mieszany/twardy) do wybranego elementu. | | `` `` | Otwórz zewnętrzne narzędzie różnic (git difftool) | | +| `` b `` | Zobacz opcje bisect | | | `` 0 `` | Focus main view | | | `` `` | Pokaż commity | | | `` / `` | Filtruj bieżący widok po tekście | | diff --git a/docs-master/keybindings/Keybindings_pt.md b/docs-master/keybindings/Keybindings_pt.md index 001fd7cb8..c396a7796 100644 --- a/docs-master/keybindings/Keybindings_pt.md +++ b/docs-master/keybindings/Keybindings_pt.md @@ -91,6 +91,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copiar nome da branch para área de transferência | | +| `` b `` | Ver opções de bissecção | | | `` i `` | Exibir opções do git-flow | | | `` `` | Verificar | Checar item selecionado | | `` n `` | Nova branch | | @@ -132,6 +133,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` s `` | Sort order | | | `` g `` | Restaurar | Ver opções de redefinição (soft/mixed/hard) para redefinir para o item selecionado. | | `` `` | Abrir ferramenta de diff externa (git difftool) | | +| `` b `` | Ver opções de bissecção | | | `` 0 `` | Focar visualização principal | | | `` `` | Ver commits | | | `` / `` | Filtrar a visualização atual por texto | | @@ -203,6 +205,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copiar etiqueta para área de transferência | | +| `` b `` | Ver opções de bissecção | | | `` `` | Verificar | Checar a tag selecionada como um HEAD, desanexado | | `` n `` | Nova etiqueta | Crie uma nova etiqueta a partir do commit atual. Você será solicitado a digitar um nome e uma descrição opcional. | | `` w `` | Nova árvore de trabalho | | @@ -285,6 +288,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | Ver opções de bissecção | | | `` `` | Verificar | Checkout the selected commit as a detached HEAD. | | `` y `` | Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). | | `` o `` | Abrir commit no navegador | | @@ -367,6 +371,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | Ver opções de bissecção | | | `` `` | Verificar | Checkout the selected commit as a detached HEAD. | | `` y `` | Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). | | `` o `` | Abrir commit no navegador | | diff --git a/docs-master/keybindings/Keybindings_ru.md b/docs-master/keybindings/Keybindings_ru.md index 3f25e0062..bb509f124 100644 --- a/docs-master/keybindings/Keybindings_ru.md +++ b/docs-master/keybindings/Keybindings_ru.md @@ -143,6 +143,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | Просмотреть параметры бинарного поиска | | | `` `` | Переключить | Checkout the selected commit as a detached HEAD. | | `` y `` | Скопировать атрибут коммита | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). | | `` o `` | Открыть коммит в браузере | | @@ -205,6 +206,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Скопировать название ветки в буфер обмена | | +| `` b `` | Просмотреть параметры бинарного поиска | | | `` i `` | Показать параметры git-flow | | | `` `` | Переключить | Checkout selected item. | | `` n `` | Новая ветка | | @@ -252,6 +254,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy abbreviated commit hash to clipboard | | +| `` b `` | Просмотреть параметры бинарного поиска | | | `` `` | Переключить | Checkout the selected commit as a detached HEAD. | | `` y `` | Скопировать атрибут коммита | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). | | `` o `` | Открыть коммит в браузере | | @@ -324,6 +327,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | Copy tag to clipboard | | +| `` b `` | Просмотреть параметры бинарного поиска | | | `` `` | Переключить | Checkout the selected tag as a detached HEAD. | | `` n `` | Создать тег | Create new tag from current commit. You'll be prompted to enter a tag name and optional description. | | `` w `` | New worktree | | @@ -350,6 +354,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` s `` | Порядок сортировки | | | `` g `` | Просмотреть параметры сброса | View reset options (soft/mixed/hard) for resetting onto selected item. | | `` `` | Open external diff tool (git difftool) | | +| `` b `` | Просмотреть параметры бинарного поиска | | | `` 0 `` | Focus main view | | | `` `` | Просмотреть коммиты | | | `` / `` | Filter the current view by text | | diff --git a/docs-master/keybindings/Keybindings_zh-CN.md b/docs-master/keybindings/Keybindings_zh-CN.md index befda4cc2..f652a607c 100644 --- a/docs-master/keybindings/Keybindings_zh-CN.md +++ b/docs-master/keybindings/Keybindings_zh-CN.md @@ -58,6 +58,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | 复制缩略提交哈希值到剪贴板 | | +| `` b `` | 查看二分查找选项 | | | `` `` | 检出 | 检出所选择的提交作为分离HEAD。 | | `` y `` | 复制提交属性到剪贴板 | 复制提交属性到剪贴板(如hash、URL、diff、消息、作者)。 | | `` o `` | 在浏览器中打开提交 | | @@ -102,6 +103,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | 复制缩略提交哈希值到剪贴板 | | +| `` b `` | 查看二分查找选项 | | | `` `` | 检出 | 检出所选择的提交作为分离HEAD。 | | `` y `` | 复制提交属性到剪贴板 | 复制提交属性到剪贴板(如hash、URL、diff、消息、作者)。 | | `` o `` | 在浏览器中打开提交 | | @@ -224,6 +226,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | 复制分支名称到剪贴板 | | +| `` b `` | 查看二分查找选项 | | | `` i `` | 显示 git-flow 选项 | | | `` `` | 检出 | 检出选中的项目 | | `` n `` | 新分支 | | @@ -255,6 +258,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | 复制标签到剪贴板 | | +| `` b `` | 查看二分查找选项 | | | `` `` | 检出 | 检出选择的标签作为分离的HEAD | | `` n `` | 创建标签 | 基于当前提交创建一个新标签。您将在弹窗中输入标签名称和描述(可选)。 | | `` w `` | 新建工作树 | | @@ -409,6 +413,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` s `` | 排序 | | | `` g `` | 查看重置选项 | 查看重置选项 (soft/mixed/hard) 用于重置到选择项 | | `` `` | 使用外部差异比较工具(git difftool) | | +| `` b `` | 查看二分查找选项 | | | `` 0 `` | 聚焦主视图 | | | `` `` | 查看提交 | | | `` / `` | 通过文本过滤当前视图 | | diff --git a/docs-master/keybindings/Keybindings_zh-TW.md b/docs-master/keybindings/Keybindings_zh-TW.md index c44b154bc..c1ca1bb8f 100644 --- a/docs-master/keybindings/Keybindings_zh-TW.md +++ b/docs-master/keybindings/Keybindings_zh-TW.md @@ -109,6 +109,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | 複製縮略提交雜湊值到剪貼簿 | | +| `` b `` | 查看二分選項 | | | `` `` | 檢出 | 檢出所選擇的提交作為分離HEAD。 | | `` y `` | 複製提交屬性 | 複製提交屬性到剪貼簿(如hash、URL、diff、訊息、作者)。 | | `` o `` | 在瀏覽器中開啟提交 | | @@ -236,6 +237,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | 複製縮略提交雜湊值到剪貼簿 | | +| `` b `` | 查看二分選項 | | | `` `` | 檢出 | 檢出所選擇的提交作為分離HEAD。 | | `` y `` | 複製提交屬性 | 複製提交屬性到剪貼簿(如hash、URL、diff、訊息、作者)。 | | `` o `` | 在瀏覽器中開啟提交 | | @@ -256,6 +258,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | 複製分支名稱到剪貼簿 | | +| `` b `` | 查看二分選項 | | | `` i `` | 顯示 git-flow 選項 | | | `` `` | 檢出 | 檢出選定的項目。 | | `` n `` | 新分支 | | @@ -287,6 +290,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | Key | Action | Info | |-----|--------|-------------| | `` `` | 複製標籤到剪貼簿 | | +| `` b `` | 查看二分選項 | | | `` `` | 檢出 | 檢出選擇的標籤作為分離的HEAD。 | | `` n `` | 建立標籤 | 基於目前提交建立一個新標籤。您將在彈窗中輸入標籤名稱和描述(可選)。 | | `` w `` | 新建工作樹 | | @@ -409,6 +413,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct | `` s `` | 排序規則 | | | `` g `` | 檢視重設選項 | 檢視重置選項 (soft/mixed/hard) 用於重置到選擇項。 | | `` `` | 開啟外部差異工具 (git difftool) | | +| `` b `` | 查看二分選項 | | | `` 0 `` | 聚焦主檢視 | | | `` `` | 檢視提交 | | | `` / `` | 搜尋 | | diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go index a580983d3..e0915915f 100644 --- a/pkg/gui/controllers.go +++ b/pkg/gui/controllers.go @@ -146,8 +146,6 @@ func (gui *Gui) resetHelpersAndControllers() { submodulesController := controllers.NewSubmodulesController(common) - bisectController := controllers.NewBisectController(common, gui.State.Contexts.LocalCommits) - commitMessageController := controllers.NewCommitMessageController( common, ) @@ -311,9 +309,19 @@ func (gui *Gui) resetHelpersAndControllers() { controllers.AttachControllers(gui.State.Contexts.LocalCommits, localCommitsController, - bisectController, ) + for _, context := range []controllers.CanBisect{ + gui.State.Contexts.LocalCommits, + gui.State.Contexts.SubCommits, + gui.State.Contexts.ReflogCommits, + gui.State.Contexts.Branches, + gui.State.Contexts.RemoteBranches, + gui.State.Contexts.Tags, + } { + controllers.AttachControllers(context, controllers.NewBisectController(common, context)) + } + controllers.AttachControllers(gui.State.Contexts.CommitFiles, commitFilesController, ) diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index b76f737e7..dd0d4dd94 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -6,6 +6,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" ) @@ -15,10 +16,15 @@ type CanBisect interface { GetSelectedRef() models.Ref } +// Offers the bisect menu for the selected item. The commits panel is where the +// user bisects: it shows the good, bad and skipped commits, and the one to test +// next. The other views only offer marking their selected item as good or bad, +// until git knows both a good and a bad commit. type BisectController struct { baseController *ListControllerTrait[models.Ref] - c *ControllerCommon + c *ControllerCommon + context CanBisect } var _ types.IController = &BisectController{} @@ -30,6 +36,7 @@ func NewBisectController( return &BisectController{ baseController: baseController{}, c: c, + context: context, ListControllerTrait: NewListControllerTrait( c, context, @@ -44,16 +51,29 @@ func NewBisectController( func (self *BisectController) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding { bindings := []*types.Binding{ { - Keys: opts.GetKeys(opts.Config.Commits.ViewBisectOptions), - Handler: opts.Guards.OutsideFilterMode(self.withItem(self.openMenu)), - Description: self.c.Tr.ViewBisectOptions, - OpensMenu: true, + Keys: opts.GetKeys(opts.Config.Commits.ViewBisectOptions), + Handler: opts.Guards.OutsideFilterMode(self.withItem(self.openMenu)), + GetDisabledReason: self.notBisectingOutsideCommitsPanel, + Description: self.c.Tr.ViewBisectOptions, + OpensMenu: true, }, } return bindings } +func (self *BisectController) isCommitsPanel() bool { + return self.context.GetKey() == context.LOCAL_COMMITS_CONTEXT_KEY +} + +func (self *BisectController) notBisectingOutsideCommitsPanel() *types.DisabledReason { + if !self.isCommitsPanel() && self.c.Model().BisectInfo.Bisecting() { + return &types.DisabledReason{Text: self.c.Tr.Bisect.UseCommitsPanel} + } + + return nil +} + func (self *BisectController) openMenu(ref models.Ref) error { // no shame in getting this directly rather than using the cached value // given how cheap it is to obtain @@ -77,16 +97,20 @@ func (self *BisectController) openMenuBeforeBisecting(info *git_commands.BisectI map[string]string{"ref": refDescription, "term": term}) } + menuItems := []*types.MenuItem{ + self.markMenuItem(markLabel(info.NewTerm()), ref.FullRefName(), info.NewTerm(), disabledReason, 'b'), + self.markMenuItem(markLabel(info.OldTerm()), ref.FullRefName(), info.OldTerm(), disabledReason, 'g'), + } + if self.isCommitsPanel() { + menuItems = append(menuItems, self.skipMenuItem( + utils.ResolvePlaceholderString(self.c.Tr.Bisect.SkipRef, map[string]string{"ref": refDescription}), + ref.FullRefName(), types.KeepCommitSelectionByHash, disabledReason, 's')) + } + menuItems = append(menuItems, self.resetMenuItem()) + return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.Bisect.BisectMenuTitle, - Items: []*types.MenuItem{ - self.markMenuItem(markLabel(info.NewTerm()), ref.FullRefName(), info.NewTerm(), disabledReason, 'b'), - self.markMenuItem(markLabel(info.OldTerm()), ref.FullRefName(), info.OldTerm(), disabledReason, 'g'), - self.skipMenuItem( - utils.ResolvePlaceholderString(self.c.Tr.Bisect.SkipRef, map[string]string{"ref": refDescription}), - ref.FullRefName(), types.KeepCommitSelectionByHash, disabledReason, 's'), - self.resetMenuItem(), - }, + Items: menuItems, }) } @@ -128,6 +152,21 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, r // Returns how the bisect menu refers to the given item. func (self *BisectController) describeRef(ref models.Ref) string { + switch ref := ref.(type) { + case *models.Branch: + // The branches view shows a detached head as a branch, too + if !ref.DetachedHead { + return utils.ResolvePlaceholderString(self.c.Tr.Bisect.BranchRef, + map[string]string{"name": ref.RefName()}) + } + case *models.RemoteBranch: + return utils.ResolvePlaceholderString(self.c.Tr.Bisect.BranchRef, + map[string]string{"name": ref.RefName()}) + case *models.Tag: + return utils.ResolvePlaceholderString(self.c.Tr.Bisect.TagRef, + map[string]string{"name": ref.RefName()}) + } + return utils.ResolvePlaceholderString(self.c.Tr.Bisect.CommitRef, map[string]string{"hash": utils.ShortHash(ref.FullRefName())}) } @@ -141,6 +180,12 @@ func (self *BisectController) markMenuItem(label string, ref string, term string return err } + if !self.isCommitsPanel() && self.c.Git().Bisect.GetInfo().Bisecting() { + // Git knows both a good and a bad commit now, so the user goes + // on in the commits panel + self.c.Context().Push(self.c.Contexts().LocalCommits, types.OnFocusOpts{}) + } + return self.afterMark(types.KeepCommitSelectionByHash) }, DisabledReason: disabledReason, @@ -175,11 +220,17 @@ func (self *BisectController) resetMenuItem() *types.MenuItem { } func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, ref models.Ref) error { + refDescription := self.describeRef(ref) + markLabel := func(term string) string { + return utils.ResolvePlaceholderString(self.c.Tr.Bisect.MarkRefStart, + map[string]string{"ref": refDescription, "term": term}) + } + return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.Bisect.BisectMenuTitle, Items: []*types.MenuItem{ { - Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, utils.ShortHash(ref.FullRefName()), info.NewTerm()), + Label: markLabel(info.NewTerm()), OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.StartBisect) if err := self.c.Git().Bisect.Start(); err != nil { @@ -197,7 +248,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, Keys: menuKey('b'), }, { - Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, utils.ShortHash(ref.FullRefName()), info.OldTerm()), + Label: markLabel(info.OldTerm()), OnPress: func() error { self.c.LogAction(self.c.Tr.Actions.StartBisect) if err := self.c.Git().Bisect.Start(); err != nil { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index c4dd71efd..0c8ed7d74 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -1039,7 +1039,7 @@ type TranslationSet struct { } type Bisect struct { - MarkStart string + MarkRefStart string ResetTitle string ResetPrompt string ResetOption string @@ -1053,6 +1053,9 @@ type Bisect struct { SkipSelected string SkipRef string CommitRef string + BranchRef string + TagRef string + UseCommitsPanel string CompleteTitle string CompletePrompt string CompletePromptIndeterminate string @@ -2374,12 +2377,15 @@ func EnglishTranslationSet() *TranslationSet { }, Bisect: Bisect{ Mark: "Mark current commit (%s) as %s", - MarkStart: "Mark %s as %s (start bisect)", + MarkRefStart: "Mark {{.ref}} as {{.term}} (start bisect)", SkipCurrent: "Skip current commit (%s)", SkipSelected: "Skip selected commit (%s)", MarkRef: "Mark {{.ref}} as {{.term}}", SkipRef: "Skip {{.ref}}", CommitRef: "commit {{.hash}}", + BranchRef: "branch '{{.name}}'", + TagRef: "tag '{{.name}}'", + UseCommitsPanel: "Bisecting is in progress; use the commits panel", ResetTitle: "Reset 'git bisect'", ResetPrompt: "Are you sure you want to reset 'git bisect'?", ResetOption: "Reset bisect", diff --git a/pkg/integration/tests/bisect/start_from_branches.go b/pkg/integration/tests/bisect/start_from_branches.go new file mode 100644 index 000000000..1e1fd80b0 --- /dev/null +++ b/pkg/integration/tests/bisect/start_from_branches.go @@ -0,0 +1,77 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StartFromBranches = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Start a bisect by marking the heads of two branches as good and bad in the branches panel", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(3). + NewBranch("feature"). + CreateNCommitsStartingAt(6, 4). + Checkout("master") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Branches(). + Focus(). + Lines( + Contains("master").IsSelected(), + Contains("feature"), + ). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("Bisect")). + Lines( + Contains("b Mark branch 'master' as bad (start bisect)"), + Contains("g Mark branch 'master' as good (start bisect)"), + Contains("t Choose bisect terms"), + Contains("Cancel"), + ). + Select(Contains("as good")).Confirm() + + t.Views().Information().Content(Contains("Bisecting")) + }). + NavigateToLine(Contains("feature")). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("Bisect")). + Lines( + Contains("b Mark branch 'feature' as bad"), + Contains("g Mark branch 'feature' as good"), + Contains("r Reset bisect"), + Contains("Cancel"), + ). + Select(Contains("as bad")).Confirm() + }) + + t.Views().Commits(). + IsFocused(). + Lines( + Contains("CI commit-09").Contains("<-- bad"), + Contains("CI commit-08"), + Contains("CI commit-07"), + Contains("CI commit-06").Contains("<-- current").IsSelected(), + Contains("CI commit-05"), + Contains("CI commit-04"), + Contains("CI commit-03").Contains("<-- good"), + Contains("CI commit-02"), + Contains("CI commit-01"), + ) + + // Once git knows both a good and a bad commit, the bisect continues in + // the commits panel + t.Views().Branches(). + Focus(). + Press(keys.Commits.ViewBisectOptions) + + t.ExpectToast(Equals("Disabled: Bisecting is in progress; use the commits panel")) + }, +}) diff --git a/pkg/integration/tests/bisect/start_from_sub_commits_and_reflog.go b/pkg/integration/tests/bisect/start_from_sub_commits_and_reflog.go new file mode 100644 index 000000000..be8cf88d0 --- /dev/null +++ b/pkg/integration/tests/bisect/start_from_sub_commits_and_reflog.go @@ -0,0 +1,70 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StartFromSubCommitsAndReflog = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Start a bisect by marking a commit of a branch as bad and a reflog entry as good", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(3). + NewBranch("feature"). + CreateNCommitsStartingAt(3, 4). + Checkout("master") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Branches(). + Focus(). + NavigateToLine(Contains("feature")). + PressEnter() + + t.Views().SubCommits(). + IsFocused(). + SelectedLine(Contains("CI commit-06")). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("Bisect")). + Lines( + MatchesRegexp(`b Mark commit [0-9a-f]+ as bad \(start bisect\)`), + MatchesRegexp(`g Mark commit [0-9a-f]+ as good \(start bisect\)`), + Contains("t Choose bisect terms"), + Contains("Cancel"), + ). + Select(Contains("as bad")).Confirm() + }). + PressEscape() + + t.Views().ReflogCommits(). + Focus(). + NavigateToLine(Contains("commit-01")). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("Bisect")). + Lines( + MatchesRegexp(`b Mark commit [0-9a-f]+ as bad`), + MatchesRegexp(`g Mark commit [0-9a-f]+ as good`), + Contains("r Reset bisect"), + Contains("Cancel"), + ). + Select(Contains("as good")).Confirm() + }) + + t.Views().Commits(). + IsFocused(). + Lines( + Contains("CI commit-06").Contains("<-- bad"), + Contains("CI commit-05"), + Contains("CI commit-04"), + Contains("CI commit-03").Contains("<-- current").IsSelected(), + Contains("CI commit-02"), + Contains("CI commit-01").Contains("<-- good"), + ) + }, +}) diff --git a/pkg/integration/tests/bisect/start_from_tags_and_remote_branches.go b/pkg/integration/tests/bisect/start_from_tags_and_remote_branches.go new file mode 100644 index 000000000..87c0a109e --- /dev/null +++ b/pkg/integration/tests/bisect/start_from_tags_and_remote_branches.go @@ -0,0 +1,76 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StartFromTagsAndRemoteBranches = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Start a bisect by marking a tag as good and a remote branch as bad", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(2). + CreateLightweightTag("v1.0", "HEAD"). + CreateNCommitsStartingAt(4, 3). + CloneIntoRemote("origin"). + HardReset("HEAD~2") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Tags(). + Focus(). + Lines( + Contains("v1.0").IsSelected(), + ). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("Bisect")). + Lines( + Contains("b Mark tag 'v1.0' as bad (start bisect)"), + Contains("g Mark tag 'v1.0' as good (start bisect)"), + Contains("t Choose bisect terms"), + Contains("Cancel"), + ). + Select(Contains("as good")).Confirm() + }) + + t.Views().Remotes(). + Focus(). + Lines( + Contains("origin").IsSelected(), + ). + PressEnter() + + t.Views().RemoteBranches(). + IsFocused(). + Lines( + Contains("master").IsSelected(), + ). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("Bisect")). + Lines( + Contains("b Mark branch 'origin/master' as bad"), + Contains("g Mark branch 'origin/master' as good"), + Contains("r Reset bisect"), + Contains("Cancel"), + ). + Select(Contains("as bad")).Confirm() + }) + + t.Views().Commits(). + IsFocused(). + Lines( + Contains("CI commit-06").Contains("<-- bad"), + Contains("CI commit-05"), + Contains("CI commit-04").Contains("<-- current").IsSelected(), + Contains("CI commit-03"), + Contains("CI v1.0 commit-02").Contains("<-- good"), + Contains("CI commit-01"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index decdd2b73..04a481279 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -42,6 +42,9 @@ var tests = []*components.IntegrationTest{ bisect.SelectCurrentCommit, bisect.SelectCurrentCommitInLongRange, bisect.Skip, + bisect.StartFromBranches, + bisect.StartFromSubCommitsAndReflog, + bisect.StartFromTagsAndRemoteBranches, branch.CheckoutAutostash, branch.CheckoutByName, branch.CheckoutPreviousBranch, From 350c061081760e4735d2e6f95019f13d68af5af3 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 31 Oct 2026 07:53:07 +0100 Subject: [PATCH 18/26] Focus the commits panel at startup when a bisect is in progress Lazygit starts in the files panel. During a bisect, this is rarely what the user needs. The commits panel shows how far the bisect has got, and the user marks the commits to test there. So start in the commits panel if a bisect is in progress, even if git doesn't know both a good and a bad commit yet. The same applies the first time the user switches to such a repo during a session. A filter path or a "status", "branch", "log" or "stash" argument still decides which panel to focus. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/gui.go | 8 +++-- .../tests/bisect/start_in_commits_panel.go | 32 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 pkg/integration/tests/bisect/start_in_commits_panel.go diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 803980c50..34da4c8af 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -666,7 +666,7 @@ func (gui *Gui) resetState(startArgs appTypes.StartArgs) types.Context { gui.applySidePanelConfig() - return initialContext(contextTree, startArgs) + return initialContext(contextTree, startArgs, gui.git.Bisect.GetInfo().Started()) } func (gui *Gui) loadCachedPullRequests() []*models.GithubPullRequest { @@ -754,7 +754,7 @@ func parseScreenModeArg(screenModeArg string) types.ScreenMode { } } -func initialContext(contextTree *context.ContextTree, startArgs appTypes.StartArgs) types.IListContext { +func initialContext(contextTree *context.ContextTree, startArgs appTypes.StartArgs, bisectStarted bool) types.IListContext { var initialContext types.IListContext = contextTree.Files if startArgs.FilterPath != "" { @@ -772,6 +772,10 @@ func initialContext(contextTree *context.ContextTree, startArgs appTypes.StartAr default: panic("unhandled git arg") } + } else if bisectStarted { + // The commits panel shows how far the bisect has got, and the user + // marks the commits to test there + initialContext = contextTree.LocalCommits } return initialContext diff --git a/pkg/integration/tests/bisect/start_in_commits_panel.go b/pkg/integration/tests/bisect/start_in_commits_panel.go new file mode 100644 index 000000000..62825e753 --- /dev/null +++ b/pkg/integration/tests/bisect/start_in_commits_panel.go @@ -0,0 +1,32 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StartInCommitsPanel = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Focus the commits panel at startup when a bisect is in progress", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(3). + // The bisect is in progress, although git knows only a bad commit + // so far + RunCommand([]string{"git", "bisect", "start"}). + RunCommand([]string{"git", "bisect", "bad"}) + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + Lines( + Contains("CI commit-03").Contains("<-- bad").IsSelected(), + Contains("CI commit-02"), + Contains("CI commit-01"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 04a481279..987713b3c 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -45,6 +45,7 @@ var tests = []*components.IntegrationTest{ bisect.StartFromBranches, bisect.StartFromSubCommitsAndReflog, bisect.StartFromTagsAndRemoteBranches, + bisect.StartInCommitsPanel, branch.CheckoutAutostash, branch.CheckoutByName, branch.CheckoutPreviousBranch, From e080c08b90bebf1c0639354b084938be20279a1e Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 31 Oct 2026 07:53:54 +0100 Subject: [PATCH 19/26] Add tests showing that a finished bisect doesn't select the first bad commit When the user marks the last commit to test as good, git reports the commit that is marked bad as the first bad commit. The commits view keeps the commit that the user just marked selected, though, so the user has to look for the result. The same happens when lazygit starts after a bisect has finished. Co-Authored-By: Claude Opus 5.5 --- .../tests/bisect/select_first_bad_commit.go | 42 +++++++++++++++++++ .../select_first_bad_commit_on_startup.go | 31 ++++++++++++++ pkg/integration/tests/test_list.go | 2 + 3 files changed, 75 insertions(+) create mode 100644 pkg/integration/tests/bisect/select_first_bad_commit.go create mode 100644 pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go diff --git a/pkg/integration/tests/bisect/select_first_bad_commit.go b/pkg/integration/tests/bisect/select_first_bad_commit.go new file mode 100644 index 000000000..1e76cba29 --- /dev/null +++ b/pkg/integration/tests/bisect/select_first_bad_commit.go @@ -0,0 +1,42 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SelectFirstBadCommit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Select the first bad commit when marking the last commit to test finishes the bisect", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(10). + StartBisect("HEAD~2", "HEAD~5") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + TopLines( + Contains("CI commit-10"), + Contains("CI commit-09"), + Contains("CI commit-08").Contains("<-- bad"), + Contains("CI commit-07").Contains("<-- current").IsSelected(), + Contains("CI commit-06"), + Contains("CI commit-05").Contains("<-- good"), + ). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + t.ExpectPopup().Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`Mark .* as good`)).Confirm() + + t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-08.*Do you want to reset")).Cancel() + }). + /* EXPECTED: + SelectedLine(Contains("CI commit-08").Contains("<-- bad")) + ACTUAL: */ + SelectedLine(Contains("CI commit-07")) + }, +}) diff --git a/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go b/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go new file mode 100644 index 000000000..00d6f4919 --- /dev/null +++ b/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go @@ -0,0 +1,31 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SelectFirstBadCommitOnStartup = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Select the first bad commit when starting with a finished bisect", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(10). + StartBisect("HEAD~2", "HEAD~5"). + // Mark commit-07, the commit that git checked out to test. This + // finishes the bisect, because commit-08 is bad. + RunCommand([]string{"git", "bisect", "good"}) + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + /* EXPECTED: + SelectedLine(Contains("CI commit-08").Contains("<-- bad")) + ACTUAL: */ + SelectedLine(Contains("CI commit-07")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 987713b3c..b0aad9c53 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -41,6 +41,8 @@ var tests = []*components.IntegrationTest{ bisect.FromOtherBranch, bisect.SelectCurrentCommit, bisect.SelectCurrentCommitInLongRange, + bisect.SelectFirstBadCommit, + bisect.SelectFirstBadCommitOnStartup, bisect.Skip, bisect.StartFromBranches, bisect.StartFromSubCommitsAndReflog, From 32d07f2b3887205f5de9830e3df39610f754bce8 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 31 Oct 2026 07:54:39 +0100 Subject: [PATCH 20/26] Select the first bad commit once a bisect is done When the user marks the last commit to test, the commits view keeps it selected, and the user has to look for the result. The same happens when lazygit starts after a bisect has finished. After a mark, git checks out the next commit to test, unless there's nothing left to test. In that case, the commit that the user marked last is still the current commit, and the commit marked bad is the first bad commit. So once the current commit is marked, select the commit marked bad instead. Do the same if git never checked out a commit to test, because the good commit is a parent of the bad one. If only skipped commits are left to test, the first bad commit is either one of them or the commit marked bad. Select the commit marked bad then too; it's the newest of the candidates. The commits view loads the commits down to the commit that it selects, so this one is always loaded. Co-Authored-By: Claude Opus 5.5 --- pkg/commands/git_commands/bisect_info.go | 15 +++++++++++++++ pkg/gui/controllers/helpers/refresh_helper.go | 11 +++++++++-- .../tests/bisect/select_first_bad_commit.go | 3 --- .../bisect/select_first_bad_commit_on_startup.go | 3 --- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/pkg/commands/git_commands/bisect_info.go b/pkg/commands/git_commands/bisect_info.go index c49d6866f..7eb5cda59 100644 --- a/pkg/commands/git_commands/bisect_info.go +++ b/pkg/commands/git_commands/bisect_info.go @@ -63,6 +63,21 @@ func (self *BisectInfo) GetCurrentHash() string { return self.current } +// Whether git has checked out a commit for the user to test, and the user +// hasn't marked it yet. After the user marks it, git checks out the next one, +// unless there's nothing left to test. This is the case if git has found the +// first new commit, or if only skipped commits are left. Git checks out the +// first commit to test once it knows both a new and an old commit, unless the +// old commit is a parent of the new one. +func (self *BisectInfo) HasCommitToTest() bool { + if self.current == "" { + return false + } + + _, marked := self.statusMap[self.current] + return !marked +} + func (self *BisectInfo) GetStartHash() string { return self.start } diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index aa1906a36..20714788f 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -1036,13 +1036,20 @@ func findNewBisectCommitToSelect(previousBisectInfo *git_commands.BisectInfo, bi } // Returns the commit that the user needs to look at during a bisect: the one -// that git wants them to test. Returns "" if there's none. +// that git wants them to test, or the first bad commit once git has found it. +// Returns "" if git doesn't know both a good and a bad commit yet. func bisectCommitToSelect(bisectInfo *git_commands.BisectInfo) string { if !bisectInfo.Bisecting() { return "" } - return bisectInfo.GetCurrentHash() + if bisectInfo.HasCommitToTest() { + return bisectInfo.GetCurrentHash() + } + + // There's nothing left to test, so the commit marked bad is the first bad + // commit. (If only skipped commits are left, it is one of the candidates.) + return bisectInfo.GetNewHash() } // capturedSubCommitState holds the sub-commits refresh's model/context/mode diff --git a/pkg/integration/tests/bisect/select_first_bad_commit.go b/pkg/integration/tests/bisect/select_first_bad_commit.go index 1e76cba29..16f86badc 100644 --- a/pkg/integration/tests/bisect/select_first_bad_commit.go +++ b/pkg/integration/tests/bisect/select_first_bad_commit.go @@ -34,9 +34,6 @@ var SelectFirstBadCommit = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-08.*Do you want to reset")).Cancel() }). - /* EXPECTED: SelectedLine(Contains("CI commit-08").Contains("<-- bad")) - ACTUAL: */ - SelectedLine(Contains("CI commit-07")) }, }) diff --git a/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go b/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go index 00d6f4919..3f0ac6bce 100644 --- a/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go +++ b/pkg/integration/tests/bisect/select_first_bad_commit_on_startup.go @@ -23,9 +23,6 @@ var SelectFirstBadCommitOnStartup = NewIntegrationTest(NewIntegrationTestArgs{ Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). IsFocused(). - /* EXPECTED: SelectedLine(Contains("CI commit-08").Contains("<-- bad")) - ACTUAL: */ - SelectedLine(Contains("CI commit-07")) }, }) From 21569fa96f86e06e60c6a9b238f50f0e8152c67c Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 31 Oct 2026 07:55:02 +0100 Subject: [PATCH 21/26] Add a test showing that a finished bisect labels the last commit "current" Once git has nothing left to test, the commit that the user marked last stays the current commit. The commits view labels it "<-- current", although it is marked good or bad now, and git doesn't want the user to test it any more. Co-Authored-By: Claude Opus 5.5 --- .../tests/bisect/select_first_bad_commit.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/integration/tests/bisect/select_first_bad_commit.go b/pkg/integration/tests/bisect/select_first_bad_commit.go index 16f86badc..2e83e1831 100644 --- a/pkg/integration/tests/bisect/select_first_bad_commit.go +++ b/pkg/integration/tests/bisect/select_first_bad_commit.go @@ -34,6 +34,16 @@ var SelectFirstBadCommit = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-08.*Do you want to reset")).Cancel() }). - SelectedLine(Contains("CI commit-08").Contains("<-- bad")) + TopLines( + Contains("CI commit-10"), + Contains("CI commit-09"), + Contains("CI commit-08").Contains("<-- bad").IsSelected(), + /* EXPECTED: + Contains("CI commit-07").Contains("<-- good"), + ACTUAL: */ + Contains("CI commit-07").Contains("<-- current"), + Contains("CI commit-06"), + Contains("CI commit-05").Contains("<-- good"), + ) }, }) From ba059498790f543bf22d419d0bf85c05d55f77e9 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 31 Oct 2026 07:55:34 +0100 Subject: [PATCH 22/26] Show the mark of the last tested commit once a bisect is done Once git has nothing left to test, the commit that the user marked last stays the current commit. The commits view labels it "<-- current", although git doesn't want the user to test it any more. Show its mark instead, like for the other marked commits. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/presentation/commits.go | 2 +- pkg/integration/tests/bisect/select_first_bad_commit.go | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index 7be1d1241..d2036aa2e 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -357,7 +357,7 @@ func getBisectStatus(index int, commitHash string, bisectInfo *git_commands.Bise return BisectStatusNone } - if bisectInfo.GetCurrentHash() == commitHash { + if bisectInfo.HasCommitToTest() && bisectInfo.GetCurrentHash() == commitHash { return BisectStatusCurrent } diff --git a/pkg/integration/tests/bisect/select_first_bad_commit.go b/pkg/integration/tests/bisect/select_first_bad_commit.go index 2e83e1831..e108dd178 100644 --- a/pkg/integration/tests/bisect/select_first_bad_commit.go +++ b/pkg/integration/tests/bisect/select_first_bad_commit.go @@ -38,10 +38,7 @@ var SelectFirstBadCommit = NewIntegrationTest(NewIntegrationTestArgs{ Contains("CI commit-10"), Contains("CI commit-09"), Contains("CI commit-08").Contains("<-- bad").IsSelected(), - /* EXPECTED: Contains("CI commit-07").Contains("<-- good"), - ACTUAL: */ - Contains("CI commit-07").Contains("<-- current"), Contains("CI commit-06"), Contains("CI commit-05").Contains("<-- good"), ) From 528481842424a857efa5c2a315d02e885c53b989 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 31 Oct 2026 08:24:53 +0100 Subject: [PATCH 23/26] Add tests showing that the bisect menu offers marks once a bisect is done Once git has nothing left to test, the bisect menu still offers marking or skipping the current commit, although the user has marked it already. This also happens if git stopped because the merge base of the good and the bad commit is bad. If git found the first bad commit without checking out anything to test, the menu acts on the selected commit, as if git didn't know both a good and a bad commit yet. Co-Authored-By: Claude Opus 5.5 --- .../offer_reset_when_merge_base_is_bad.go | 44 +++++++++++++++++++ .../tests/bisect/show_result_again.go | 41 +++++++++++++++++ .../show_result_when_found_right_away.go | 44 +++++++++++++++++++ pkg/integration/tests/test_list.go | 3 ++ 4 files changed, 132 insertions(+) create mode 100644 pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go create mode 100644 pkg/integration/tests/bisect/show_result_again.go create mode 100644 pkg/integration/tests/bisect/show_result_when_found_right_away.go diff --git a/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go b/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go new file mode 100644 index 000000000..2c8b9302a --- /dev/null +++ b/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go @@ -0,0 +1,44 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var OfferResetWhenMergeBaseIsBad = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Offer to reset instead of showing the bisect menu when git stopped because the merge base is bad", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(2). + NewBranch("fixed"). + CreateNCommitsStartingAt(1, 3). + Checkout("master"). + CreateNCommitsStartingAt(2, 4). + // Git checks out the merge base commit-02 to test first. If it is + // bad, git can't find the first bad commit, and stops. + StartBisect("master", "fixed"). + RunCommandExpectError([]string{"git", "bisect", "bad"}) + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + Lines( + Contains("CI commit-05"), + Contains("CI commit-04"), + Contains("CI commit-02").Contains("<-- bad").IsSelected(), + Contains("CI commit-01"), + ). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + /* EXPECTED: + t.ExpectPopup().Confirmation().Title(Equals("Reset 'git bisect'")).Content(Equals("Are you sure you want to reset 'git bisect'?")).Cancel() + ACTUAL: */ + t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(Contains("Mark current commit")).Cancel() + }) + }, +}) diff --git a/pkg/integration/tests/bisect/show_result_again.go b/pkg/integration/tests/bisect/show_result_again.go new file mode 100644 index 000000000..ac2406732 --- /dev/null +++ b/pkg/integration/tests/bisect/show_result_again.go @@ -0,0 +1,41 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var ShowResultAgain = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Show the result of a finished bisect again instead of the bisect menu", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(10). + StartBisect("HEAD~2", "HEAD~5"). + // Mark commit-07, the commit that git checked out to test. This + // finishes the bisect, because commit-08 is bad. + RunCommand([]string{"git", "bisect", "good"}) + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + SelectedLine(Contains("CI commit-08").Contains("<-- bad")). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + /* EXPECTED: + t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-08.*Do you want to reset")).Cancel() + ACTUAL: */ + t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(Contains("Mark current commit")).Cancel() + }) + + t.Views().Branches(). + Focus(). + Press(keys.Commits.ViewBisectOptions) + + t.ExpectToast(Equals("Disabled: Bisecting is in progress; use the commits panel")) + }, +}) diff --git a/pkg/integration/tests/bisect/show_result_when_found_right_away.go b/pkg/integration/tests/bisect/show_result_when_found_right_away.go new file mode 100644 index 000000000..98f4fd7a8 --- /dev/null +++ b/pkg/integration/tests/bisect/show_result_when_found_right_away.go @@ -0,0 +1,44 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var ShowResultWhenFoundRightAway = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Show the result instead of the bisect menu when git found the first bad commit without testing any", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(3). + // The good commit is the parent of the bad one, so git doesn't + // check out anything to test + StartBisect("HEAD", "HEAD~1") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + Lines( + Contains("CI commit-03").Contains("<-- bad").IsSelected(), + Contains("CI commit-02").Contains("<-- good"), + Contains("CI commit-01"), + ). + Press(keys.Commits.ViewBisectOptions). + Tap(func() { + /* EXPECTED: + t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-03.*Do you want to reset")).Cancel() + ACTUAL: */ + t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(MatchesRegexp(`b Mark commit [0-9a-f]+ as bad`)).Cancel() + }) + + t.Views().Branches(). + Focus(). + Press(keys.Commits.ViewBisectOptions) + + t.ExpectToast(Equals("Disabled: Bisecting is in progress; use the commits panel")) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index b0aad9c53..4122c1188 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -39,10 +39,13 @@ var tests = []*components.IntegrationTest{ bisect.CheckOutBranchBeforeBisecting, bisect.ChooseTerms, bisect.FromOtherBranch, + bisect.OfferResetWhenMergeBaseIsBad, bisect.SelectCurrentCommit, bisect.SelectCurrentCommitInLongRange, bisect.SelectFirstBadCommit, bisect.SelectFirstBadCommitOnStartup, + bisect.ShowResultAgain, + bisect.ShowResultWhenFoundRightAway, bisect.Skip, bisect.StartFromBranches, bisect.StartFromSubCommitsAndReflog, From 368633f69cb0d220c16f76ae09b054584e520d41 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 31 Oct 2026 08:25:45 +0100 Subject: [PATCH 24/26] Show the result of a finished bisect instead of the bisect menu Once git has nothing left to test, the bisect menu offers marking or skipping the current commit, although the user has marked it already. If git found the first bad commit without checking out anything to test, the menu acts on the selected commit instead, as if git didn't know both a good and a bad commit yet. At this point, the user wants to see the result and reset the bisect. Show the "Bisect complete" dialog again instead of the menu. It names the first bad commit and asks whether to reset the bisect. This also lets the user see the result again after declining the reset when the bisect finished. If git stopped without finding the first bad commit, because the merge base of the good and the bad commit is bad, show the confirmation for resetting the bisect. Git said why it stopped when it did. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/controllers/bisect_controller.go | 23 ++++++++++++++++++- .../offer_reset_when_merge_base_is_bad.go | 3 --- .../tests/bisect/show_result_again.go | 3 --- .../show_result_when_found_right_away.go | 3 --- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index dd0d4dd94..36d43692f 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -81,12 +81,33 @@ func (self *BisectController) openMenu(ref models.Ref) error { if !info.Started() { return self.openStartBisectMenu(info, ref) } - if info.GetCurrentHash() == "" { + if !info.Bisecting() { return self.openMenuBeforeBisecting(info, ref) } + if !info.HasCommitToTest() { + return self.showBisectResult() + } return self.openMidBisectMenu(info, ref) } +// Git has nothing left for the user to test, so show the result, and offer to +// reset the bisect. +func (self *BisectController) showBisectResult() error { + done, candidateHashes, err := self.c.Git().Bisect.IsDone() + if err != nil { + return err + } + + if !done { + // Git stopped without finding the first bad commit, for example + // because the merge base of the good and the bad commit is bad. Git + // said why when it stopped, so all that's left to do is to reset. + return self.c.Helpers().Bisect.Reset() + } + + return self.showBisectCompleteMessage(candidateHashes) +} + // The menu for when a bisect has started, but git doesn't know both a good and // a bad commit yet. Its entries act on the selected item. func (self *BisectController) openMenuBeforeBisecting(info *git_commands.BisectInfo, ref models.Ref) error { diff --git a/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go b/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go index 2c8b9302a..a9758e6e2 100644 --- a/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go +++ b/pkg/integration/tests/bisect/offer_reset_when_merge_base_is_bad.go @@ -35,10 +35,7 @@ var OfferResetWhenMergeBaseIsBad = NewIntegrationTest(NewIntegrationTestArgs{ ). Press(keys.Commits.ViewBisectOptions). Tap(func() { - /* EXPECTED: t.ExpectPopup().Confirmation().Title(Equals("Reset 'git bisect'")).Content(Equals("Are you sure you want to reset 'git bisect'?")).Cancel() - ACTUAL: */ - t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(Contains("Mark current commit")).Cancel() }) }, }) diff --git a/pkg/integration/tests/bisect/show_result_again.go b/pkg/integration/tests/bisect/show_result_again.go index ac2406732..073cf1456 100644 --- a/pkg/integration/tests/bisect/show_result_again.go +++ b/pkg/integration/tests/bisect/show_result_again.go @@ -26,10 +26,7 @@ var ShowResultAgain = NewIntegrationTest(NewIntegrationTestArgs{ SelectedLine(Contains("CI commit-08").Contains("<-- bad")). Press(keys.Commits.ViewBisectOptions). Tap(func() { - /* EXPECTED: t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-08.*Do you want to reset")).Cancel() - ACTUAL: */ - t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(Contains("Mark current commit")).Cancel() }) t.Views().Branches(). diff --git a/pkg/integration/tests/bisect/show_result_when_found_right_away.go b/pkg/integration/tests/bisect/show_result_when_found_right_away.go index 98f4fd7a8..ea74ebe04 100644 --- a/pkg/integration/tests/bisect/show_result_when_found_right_away.go +++ b/pkg/integration/tests/bisect/show_result_when_found_right_away.go @@ -29,10 +29,7 @@ var ShowResultWhenFoundRightAway = NewIntegrationTest(NewIntegrationTestArgs{ ). Press(keys.Commits.ViewBisectOptions). Tap(func() { - /* EXPECTED: t.ExpectPopup().Alert().Title(Equals("Bisect complete")).Content(MatchesRegexp("(?s)commit-03.*Do you want to reset")).Cancel() - ACTUAL: */ - t.ExpectPopup().Menu().Title(Equals("Bisect")).TopLines(MatchesRegexp(`b Mark commit [0-9a-f]+ as bad`)).Cancel() }) t.Views().Branches(). From fd7178a3a96603bbf9e6843c127629eb3c4c89d7 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 31 Oct 2026 12:15:16 +0100 Subject: [PATCH 25/26] Add tests showing that some commits to bisect lack the "?" mark The commits view marks the commits between the bad commit and the first good commit in the list with a "?". If there's no good commit in the list, it doesn't mark any. This is the case while git tests the merge base of a good and a bad commit on different branches. It's also the case early in a long bisect, when the good commit is further down than the commits that we load. Co-Authored-By: Claude Opus 5.5 --- ...ark_candidates_while_testing_merge_base.go | 41 +++++++++++++++++++ .../select_current_commit_in_long_range.go | 12 +++++- pkg/integration/tests/test_list.go | 1 + 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 pkg/integration/tests/bisect/mark_candidates_while_testing_merge_base.go diff --git a/pkg/integration/tests/bisect/mark_candidates_while_testing_merge_base.go b/pkg/integration/tests/bisect/mark_candidates_while_testing_merge_base.go new file mode 100644 index 000000000..7e8994dc6 --- /dev/null +++ b/pkg/integration/tests/bisect/mark_candidates_while_testing_merge_base.go @@ -0,0 +1,41 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var MarkCandidatesWhileTestingMergeBase = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Mark the commits that the bisect hasn't ruled out yet while git tests the merge base of the good and the bad commit", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(2). + NewBranch("fixed"). + CreateNCommitsStartingAt(1, 3). + Checkout("master"). + CreateNCommitsStartingAt(2, 4). + // The good commit-03 is on another branch, so git checks out the + // merge base commit-02 to test first + StartBisect("master", "fixed") + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + Lines( + Contains("CI commit-05").Contains("<-- bad"), + /* EXPECTED: + MatchesRegexp(`\?.*commit-04`), + ACTUAL: */ + Contains("CI commit-04").DoesNotContain("?"), + Contains("CI commit-02").Contains("<-- current").IsSelected(), + // This is an ancestor of the good commit-03, so the bisect has + // ruled it out + Contains("CI commit-01").DoesNotContain("?"), + ) + }, +}) diff --git a/pkg/integration/tests/bisect/select_current_commit_in_long_range.go b/pkg/integration/tests/bisect/select_current_commit_in_long_range.go index 09794c59f..5f0caa183 100644 --- a/pkg/integration/tests/bisect/select_current_commit_in_long_range.go +++ b/pkg/integration/tests/bisect/select_current_commit_in_long_range.go @@ -8,7 +8,7 @@ import ( ) var SelectCurrentCommitInLongRange = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Select the current bisect commit when it is further down than the commits that we load at first", + Description: "Select the current bisect commit when it is further down than the commits that we load at first, and mark the commits around it that the bisect hasn't ruled out yet", ExtraCmdArgs: []string{}, Skip: false, SetupRepo: func(shell *Shell) { @@ -23,6 +23,14 @@ var SelectCurrentCommitInLongRange = NewIntegrationTest(NewIntegrationTestArgs{ Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). - SelectedLine(Contains("<-- current")) + SelectedLine(Contains("<-- current")). + // The commits between the current one and the good one are still + // to be tested. The good one is further down than the commits that + // we load. + SelectNextItem(). + /* EXPECTED: + SelectedLine(Contains("?")) + ACTUAL: */ + SelectedLine(DoesNotContain("?")) }, }) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 4122c1188..acbe5b445 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -39,6 +39,7 @@ var tests = []*components.IntegrationTest{ bisect.CheckOutBranchBeforeBisecting, bisect.ChooseTerms, bisect.FromOtherBranch, + bisect.MarkCandidatesWhileTestingMergeBase, bisect.OfferResetWhenMergeBaseIsBad, bisect.SelectCurrentCommit, bisect.SelectCurrentCommitInLongRange, From 0b87c9e6101b8016acf50d1c8f6900538eb44a7e Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 31 Oct 2026 12:17:43 +0100 Subject: [PATCH 26/26] Ask git which commits a bisect hasn't ruled out yet The commits view marks the commits that a bisect hasn't ruled out yet with a "?". To find them, it looks for the bad commit and the first good commit in the list, and marks the commits between them. If there's no good commit in the list, it marks none. This is the case while git tests the merge base of a good and a bad commit on different branches. It's also the case early in a long bisect, when the good commit is further down than the commits that we load. With merges, the commits between the two can also include some that the bisect has ruled out. Ask git instead, with "git rev-list --not ...", when refreshing the commits while git knows both a good and a bad commit. This takes about as long as the git log that loads the commits, or less, and it gets faster as the bisect goes on. Keep only the commits that the commits view has loaded, because git may list many more. Co-Authored-By: Claude Opus 5.5 --- pkg/commands/git_commands/bisect.go | 38 +++++++++++++++ pkg/commands/git_commands/bisect_info.go | 14 ++++++ pkg/gui/controllers/helpers/refresh_helper.go | 3 ++ pkg/gui/presentation/commits.go | 46 +++---------------- ...ark_candidates_while_testing_merge_base.go | 3 -- .../select_current_commit_in_long_range.go | 3 -- 6 files changed, 62 insertions(+), 45 deletions(-) diff --git a/pkg/commands/git_commands/bisect.go b/pkg/commands/git_commands/bisect.go index e554af117..96fed84ae 100644 --- a/pkg/commands/git_commands/bisect.go +++ b/pkg/commands/git_commands/bisect.go @@ -5,6 +5,10 @@ import ( "path/filepath" "strconv" "strings" + + "github.com/jesseduffield/generics/set" + "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/samber/lo" ) type BisectCommands struct { @@ -181,6 +185,40 @@ func (self *BisectCommands) IsDone() (bool, []string, error) { return done, candidates, nil } +// Asks git which of the given commits the bisect hasn't ruled out yet, and +// stores them in the bisect info. Git may list many more commits than these, +// so we don't keep the others. +func (self *BisectCommands) LoadCandidates(info *BisectInfo, commits []*models.Commit) error { + if !info.Bisecting() { + return nil + } + + oldHashes := lo.Keys(lo.PickBy(info.statusMap, func(_ string, status BisectStatus) bool { + return status == BisectStatusOld + })) + cmdArgs := NewGitCmd("rev-list"). + Arg(info.GetNewHash(), "--not"). + Arg(oldHashes...). + ToArgv() + + loadedHashes := set.NewFromSlice(lo.Map(commits, func(commit *models.Commit, _ int) string { + return commit.Hash() + })) + candidates := set.New[string]() + err := self.cmd.New(cmdArgs).DontLog().RunAndProcessLines(func(line string) (bool, error) { + if hash := strings.TrimSpace(line); loadedHashes.Includes(hash) { + candidates.Add(hash) + } + return false, nil + }) + if err != nil { + return err + } + + info.candidates = candidates + return nil +} + // tells us whether the 'start' ref that we'll be sent back to after we're done // bisecting is actually a descendant of our current bisect commit. If it's not, we need to // render the commits from the bad commit. diff --git a/pkg/commands/git_commands/bisect_info.go b/pkg/commands/git_commands/bisect_info.go index 7eb5cda59..c364b1fa4 100644 --- a/pkg/commands/git_commands/bisect_info.go +++ b/pkg/commands/git_commands/bisect_info.go @@ -2,6 +2,7 @@ package git_commands import ( "github.com/jesseduffield/generics/maps" + "github.com/jesseduffield/generics/set" "github.com/samber/lo" "github.com/sirupsen/logrus" ) @@ -34,6 +35,11 @@ type BisectInfo struct { // the hash of the commit that's under test current string + + // the commits that the bisect hasn't ruled out yet, among those that the + // commits view has loaded. Nil until BisectCommands.LoadCandidates is + // called. + candidates *set.Set[string] } type BisectStatus int @@ -78,6 +84,14 @@ func (self *BisectInfo) HasCommitToTest() bool { return !marked } +// Whether the bisect hasn't ruled out the commit yet. This is the case if the +// new commit can reach it, but no old one can, so it includes the new commit +// and the skipped ones. Only known for the commits that the commits view has +// loaded. +func (self *BisectInfo) IsCandidate(commitHash string) bool { + return self.candidates != nil && self.candidates.Includes(commitHash) +} + func (self *BisectInfo) GetStartHash() string { return self.start } diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 20714788f..d1356c2aa 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -871,6 +871,9 @@ func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, if err != nil { return err } + if err := env.git.Bisect.LoadCandidates(bisectInfo, commits); err != nil { + self.c.Log.Warnf("Failed to find the commits that the bisect hasn't ruled out yet: %v", err) + } workingTreeState := env.git.Status.WorkingTreeState() self.onUIThreadUnlessRepoChanged(env, func() { diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index d2036aa2e..28fc356bf 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -36,11 +36,6 @@ var ( pipeSetCacheAuthorColors = authors.ColorsVersion() ) -type bisectBounds struct { - newIndex int - oldIndex int -} - func GetCommitListDisplayStrings( common *common.Common, commits []*models.Commit, @@ -78,8 +73,6 @@ func GetCommitListDisplayStrings( filteredCommits := commits[startIdx:endIdx] - bisectBounds := getbisectBounds(commits, bisectInfo) - // function expects to be passed the index of the commit in terms of the `commits` slice var getGraphLine func(int) string if showGraph { @@ -187,14 +180,14 @@ func GetCommitListDisplayStrings( reservedWidths := getReservedColumnWidths( commits, common.UserConfig().Gui.CommitHashLength, fullDescription, - timeFormat, shortTimeFormat, now, bisectInfo, bisectBounds) + timeFormat, shortTimeFormat, now, bisectInfo) lines := make([][]string, 0, len(filteredCommits)) var bisectStatus BisectStatus willBeRebased := markedBaseCommit == "" for i, commit := range filteredCommits { unfilteredIdx := i + startIdx - bisectStatus = getBisectStatus(unfilteredIdx, commit.Hash(), bisectInfo, bisectBounds) + bisectStatus = getBisectStatus(commit.Hash(), bisectInfo) isMarkedBaseCommit := commit.Hash() != "" && commit.Hash() == markedBaseCommit if isMarkedBaseCommit { willBeRebased = true @@ -243,16 +236,15 @@ func getReservedColumnWidths( shortTimeFormat string, now time.Time, bisectInfo *git_commands.BisectInfo, - bisectBounds *bisectBounds, ) reservedColumnWidths { result := reservedColumnWidths{} - for i, commit := range commits { + for _, commit := range commits { result.hash = max(result.hash, utils.StringWidth(getHashText(commit, hashLength))) if commit.IsTODO() { result.action = max(result.action, utils.StringWidth(getActionText(commit))) } - bisectStatus := getBisectStatus(i, commit.Hash(), bisectInfo, bisectBounds) + bisectStatus := getBisectStatus(commit.Hash(), bisectInfo) result.bisect = max(result.bisect, utils.StringWidth(getBisectStatusText(bisectStatus, bisectInfo))) } @@ -274,29 +266,6 @@ func getReservedColumnWidths( return result } -func getbisectBounds(commits []*models.Commit, bisectInfo *git_commands.BisectInfo) *bisectBounds { - if !bisectInfo.Bisecting() { - return nil - } - - bisectBounds := &bisectBounds{} - - for i, commit := range commits { - if commit.Hash() == bisectInfo.GetNewHash() { - bisectBounds.newIndex = i - } - - status, ok := bisectInfo.Status(commit.Hash()) - if ok && status == git_commands.BisectStatusOld { - bisectBounds.oldIndex = i - return bisectBounds - } - } - - // shouldn't land here - return nil -} - // precondition: slice is not empty func indexOfFirstNonTODOCommit(commits []*models.Commit) int { for i, commit := range commits { @@ -345,14 +314,13 @@ const ( BisectStatusOld BisectStatusNew BisectStatusSkipped - // adding candidate here which isn't present in the commands package because - // we need to actually go through the commits to get this info + // a commit that has no mark, and that the bisect hasn't ruled out yet BisectStatusCandidate // also adding this BisectStatusCurrent ) -func getBisectStatus(index int, commitHash string, bisectInfo *git_commands.BisectInfo, bisectBounds *bisectBounds) BisectStatus { +func getBisectStatus(commitHash string, bisectInfo *git_commands.BisectInfo) BisectStatus { if !bisectInfo.Started() { return BisectStatusNone } @@ -372,7 +340,7 @@ func getBisectStatus(index int, commitHash string, bisectInfo *git_commands.Bise return BisectStatusSkipped } } else { - if bisectBounds != nil && index >= bisectBounds.newIndex && index <= bisectBounds.oldIndex { + if bisectInfo.IsCandidate(commitHash) { return BisectStatusCandidate } return BisectStatusNone diff --git a/pkg/integration/tests/bisect/mark_candidates_while_testing_merge_base.go b/pkg/integration/tests/bisect/mark_candidates_while_testing_merge_base.go index 7e8994dc6..a9aa717eb 100644 --- a/pkg/integration/tests/bisect/mark_candidates_while_testing_merge_base.go +++ b/pkg/integration/tests/bisect/mark_candidates_while_testing_merge_base.go @@ -28,10 +28,7 @@ var MarkCandidatesWhileTestingMergeBase = NewIntegrationTest(NewIntegrationTestA IsFocused(). Lines( Contains("CI commit-05").Contains("<-- bad"), - /* EXPECTED: MatchesRegexp(`\?.*commit-04`), - ACTUAL: */ - Contains("CI commit-04").DoesNotContain("?"), Contains("CI commit-02").Contains("<-- current").IsSelected(), // This is an ancestor of the good commit-03, so the bisect has // ruled it out diff --git a/pkg/integration/tests/bisect/select_current_commit_in_long_range.go b/pkg/integration/tests/bisect/select_current_commit_in_long_range.go index 5f0caa183..6a733ed49 100644 --- a/pkg/integration/tests/bisect/select_current_commit_in_long_range.go +++ b/pkg/integration/tests/bisect/select_current_commit_in_long_range.go @@ -28,9 +28,6 @@ var SelectCurrentCommitInLongRange = NewIntegrationTest(NewIntegrationTestArgs{ // to be tested. The good one is further down than the commits that // we load. SelectNextItem(). - /* EXPECTED: SelectedLine(Contains("?")) - ACTUAL: */ - SelectedLine(DoesNotContain("?")) }, })