From 4055495c8ba983033459507f3032ca93c6ec006a Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 29 Sep 2020 20:16:15 +0200 Subject: repo: fix wrong ordering in gogit's ListCommit --- repository/gogit.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'repository/gogit.go') diff --git a/repository/gogit.go b/repository/gogit.go index aac89d4b..09f714ea 100644 --- a/repository/gogit.go +++ b/repository/gogit.go @@ -536,16 +536,14 @@ func (repo *GoGitRepo) ListCommits(ref string) ([]Hash, error) { if err != nil { return nil, err } - commits := []Hash{Hash(commit.Hash.String())} + hashes := []Hash{Hash(commit.Hash.String())} for { commit, err = commit.Parent(0) - + if err == object.ErrParentNotFound { + break + } if err != nil { - if err == object.ErrParentNotFound { - break - } - return nil, err } @@ -553,10 +551,10 @@ func (repo *GoGitRepo) ListCommits(ref string) ([]Hash, error) { return nil, fmt.Errorf("multiple parents") } - commits = append(commits, Hash(commit.Hash.String())) + hashes = append([]Hash{Hash(commit.Hash.String())}, hashes...) } - return commits, nil + return hashes, nil } // GetOrCreateClock return a Lamport clock stored in the Repo. -- cgit