summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-06-27 19:11:38 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-07-10 13:42:35 +0200
commitcc316ab6de40c3b6fd3666b5ce0241eeee4680e8 (patch)
tree279b9091ca0462bb606c23347d25c65b694f3c88 /pkg
parent8f00bfebcee681477c36e7c252180cc01f6d2125 (diff)
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.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/git_commands/commit_loader.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go
index 148c96776..32d470fc8 100644
--- a/pkg/commands/git_commands/commit_loader.go
+++ b/pkg/commands/git_commands/commit_loader.go
@@ -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)