Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/gitaly-git2go/util.go')
-rw-r--r--cmd/gitaly-git2go/util.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/cmd/gitaly-git2go/util.go b/cmd/gitaly-git2go/util.go
new file mode 100644
index 000000000..7a94371c3
--- /dev/null
+++ b/cmd/gitaly-git2go/util.go
@@ -0,0 +1,28 @@
+//go:build static && system_libgit2
+
+package main
+
+import (
+ "fmt"
+
+ git "github.com/libgit2/git2go/v33"
+)
+
+func lookupCommit(repo *git.Repository, ref string) (*git.Commit, error) {
+ object, err := repo.RevparseSingle(ref)
+ if err != nil {
+ return nil, fmt.Errorf("lookup commit %q: %w", ref, err)
+ }
+
+ peeled, err := object.Peel(git.ObjectCommit)
+ if err != nil {
+ return nil, fmt.Errorf("lookup commit %q: peel: %w", ref, err)
+ }
+
+ commit, err := peeled.AsCommit()
+ if err != nil {
+ return nil, fmt.Errorf("lookup commit %q: as commit: %w", ref, err)
+ }
+
+ return commit, nil
+}