mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-04 10:34:55 +02:00
Fix interactive rebase with git 2.25.1 and earlier
The code in getHydratedRebasingCommits relied on the assumption that the git-rebase-todo file contains full SHAs. This has only been true from 2.25.2 on, before that it would contain abbreviated SHAs. Fix this by storing fullCommits in a slice instead of a map, and using a linear search.
This commit is contained in:
parent
8f00bfebce
commit
cc316ab6de
@ -222,11 +222,24 @@ func (self *CommitLoader) getHydratedRebasingCommits(rebaseMode enums.RebaseMode
|
||||
return nil, err
|
||||
}
|
||||
|
||||
findFullCommit := lo.Ternary(self.version.IsOlderThan(2, 25, 2),
|
||||
func(sha string) *models.Commit {
|
||||
for s, c := range fullCommits {
|
||||
if strings.HasPrefix(s, sha) {
|
||||
return c
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(sha string) *models.Commit {
|
||||
return fullCommits[sha]
|
||||
})
|
||||
|
||||
hydratedCommits := make([]*models.Commit, 0, len(commits))
|
||||
for _, rebasingCommit := range commits {
|
||||
if rebasingCommit.Sha == "" {
|
||||
hydratedCommits = append(hydratedCommits, rebasingCommit)
|
||||
} else if commit := fullCommits[rebasingCommit.Sha]; commit != nil {
|
||||
} else if commit := findFullCommit(rebasingCommit.Sha); commit != nil {
|
||||
commit.Action = rebasingCommit.Action
|
||||
commit.Status = rebasingCommit.Status
|
||||
hydratedCommits = append(hydratedCommits, commit)
|
||||
|
Loading…
Reference in New Issue
Block a user