1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-28 16:02:01 +03:00

only show commits from start ref if bad commit is reachable from there

This commit is contained in:
Jesse Duffield
2022-01-26 15:17:11 +11:00
parent dc765c4166
commit ca7cfc3232
3 changed files with 26 additions and 9 deletions

View File

@ -162,3 +162,11 @@ func (self *BisectCommands) IsDone() (bool, []string, error) {
return done, candidates, nil
}
func (self *BisectCommands) ReachableFromStart(ref string, startRef string) bool {
err := self.cmd.New(
fmt.Sprintf("git merge-base --is-ancestor %s %s", startRef, ref),
).Run()
return err == nil
}

View File

@ -116,19 +116,12 @@ func (gui *Gui) refreshCommitsWithLimit() error {
gui.Mutexes.BranchCommitsMutex.Lock()
defer gui.Mutexes.BranchCommitsMutex.Unlock()
refName := "HEAD"
bisectInfo := gui.Git.Bisect.GetInfo()
gui.State.BisectInfo = bisectInfo
if bisectInfo.Started() {
refName = bisectInfo.StartSha()
}
commits, err := gui.Git.Loaders.Commits.GetCommits(
loaders.GetCommitsOptions{
Limit: gui.State.Panels.Commits.LimitCommits,
FilterPath: gui.State.Modes.Filtering.GetPath(),
IncludeRebaseCommits: true,
RefName: refName,
RefName: gui.refForLog(),
All: gui.State.ShowWholeGitGraph,
},
)
@ -140,6 +133,22 @@ func (gui *Gui) refreshCommitsWithLimit() error {
return gui.postRefreshUpdate(gui.State.Contexts.BranchCommits)
}
func (gui *Gui) refForLog() string {
bisectInfo := gui.Git.Bisect.GetInfo()
gui.State.BisectInfo = bisectInfo
if !bisectInfo.Started() {
return "HEAD"
}
// need to see if our bisect's current commit is reachable from our 'start' ref.
if bisectInfo.Bisecting() && !gui.Git.Bisect.ReachableFromStart(bisectInfo.StartSha(), bisectInfo.GetCurrentSha()) {
return bisectInfo.GetNewSha()
}
return bisectInfo.StartSha()
}
func (gui *Gui) refreshRebaseCommits() error {
gui.Mutexes.BranchCommitsMutex.Lock()
defer gui.Mutexes.BranchCommitsMutex.Unlock()

View File

@ -175,7 +175,7 @@ func getBisectStatus(commitSha string, bisectInfo *git_commands.BisectInfo, bise
return BisectStatusSkipped, bisectProgress
}
} else {
if bisectProgress == InbetweenCommits {
if bisectProgress == InbetweenCommits && bisectInfo.Bisecting() {
return BisectStatusCandidate, bisectProgress
} else {
return BisectStatusNone, bisectProgress