Store Commit.Parents in the pool too

We need to pass %P instead of %p in the format string of the git log command, so
that the parent hashes have the full length and can be shared with the real
hashes.
This commit is contained in:
Stefan Haller 2025-04-19 17:34:53 +02:00
parent 0f1f455edb
commit 722cc85508
5 changed files with 19 additions and 18 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/samber/lo"
"github.com/stefanhaller/git-todo-parser/todo"
)
@ -54,7 +55,7 @@ type Commit struct {
Divergence Divergence // set to DivergenceNone unless we are showing the divergence view
// Hashes of parent commits (will be multiple if it's a merge commit)
parents []string
parents []*string
}
type NewCommitOpts struct {
@ -83,7 +84,7 @@ func NewCommit(hashPool *utils.StringPool, opts NewCommitOpts) *Commit {
AuthorEmail: opts.AuthorEmail,
UnixTimestamp: opts.UnixTimestamp,
Divergence: opts.Divergence,
parents: opts.Parents,
parents: lo.Map(opts.Parents, func(s string, _ int) *string { return hashPool.Add(s) }),
}
}
@ -115,7 +116,7 @@ func (c *Commit) ParentRefName() string {
}
func (c *Commit) Parents() []string {
return c.parents
return lo.Map(c.parents, func(s *string, _ int) string { return *s })
}
func (c *Commit) IsFirstCommit() bool {