summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/grv/repo_data.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/cmd/grv/repo_data.go b/cmd/grv/repo_data.go
index fe9d074..5b01527 100644
--- a/cmd/grv/repo_data.go
+++ b/cmd/grv/repo_data.go
@@ -67,6 +67,7 @@ type RepoData interface {
CommitByIndex(ref Ref, index uint) (*Commit, error)
Commit(oid *Oid) (*Commit, error)
CommitByOid(oidStr string) (*Commit, error)
+ CommitParents(oid *Oid) ([]*Commit, error)
AddCommitFilter(Ref, *CommitFilter) error
RemoveCommitFilter(Ref) error
DiffCommit(commit *Commit) (*Diff, error)
@@ -1276,6 +1277,29 @@ func (repoData *RepositoryData) CommitByOid(oidStr string) (*Commit, error) {
return repoData.repoDataLoader.CommitByOid(oidStr)
}
+// CommitParents loads the parents of a commit
+func (repoData *RepositoryData) CommitParents(oid *Oid) (parentCommits []*Commit, err error) {
+ commit, err := repoData.repoDataLoader.Commit(oid)
+ if err != nil {
+ return
+ }
+
+ parentCount := commit.commit.ParentCount()
+ var parentCommit *Commit
+
+ for i := uint(0); i < parentCount; i++ {
+ parentOid := &Oid{commit.commit.ParentId(i)}
+ parentCommit, err = repoData.Commit(parentOid)
+ if err != nil {
+ return
+ }
+
+ parentCommits = append(parentCommits, parentCommit)
+ }
+
+ return
+}
+
// AddCommitFilter adds the filter to the specified ref
func (repoData *RepositoryData) AddCommitFilter(ref Ref, commitFilter *CommitFilter) error {
return repoData.refCommitSets.addCommitFilter(ref, commitFilter)