Make Commit.Parents a getter for an unexported parents field

This is exactly the same as what we did for Hash earlier. And for the same
reason: we want to turn the parents field into a slice of pointers.
This commit is contained in:
Stefan Haller 2025-04-26 19:58:03 +02:00
parent e27bc15bbd
commit 0f1f455edb
4 changed files with 13 additions and 9 deletions

View file

@ -54,7 +54,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 +83,7 @@ func NewCommit(hashPool *utils.StringPool, opts NewCommitOpts) *Commit {
AuthorEmail: opts.AuthorEmail,
UnixTimestamp: opts.UnixTimestamp,
Divergence: opts.Divergence,
Parents: opts.Parents,
parents: opts.Parents,
}
}
@ -114,8 +114,12 @@ func (c *Commit) ParentRefName() string {
return c.RefName() + "^"
}
func (c *Commit) Parents() []string {
return c.parents
}
func (c *Commit) IsFirstCommit() bool {
return len(c.Parents) == 0
return len(c.parents) == 0
}
func (c *Commit) ID() string {
@ -127,7 +131,7 @@ func (c *Commit) Description() string {
}
func (c *Commit) IsMerge() bool {
return len(c.Parents) > 1
return len(c.parents) > 1
}
// returns true if this commit is not actually in the git log but instead