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:
authorToon Claes <toon@gitlab.com>2022-07-13 22:27:40 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-18 12:04:56 +0300
commitccd4fc13f64a8be8e0fb3d27678285d444436473 (patch)
treea75a92aa53a77e2f33c3118e33d8189c66e96246
parentd052f272062fcf4a730eaf18511542538a68aa53 (diff)
gittest: Use empty tree oid with correct hash
Depending on the object format of the repo, the hash for an empty tree will be different. This change adapts to that.
-rw-r--r--internal/git/gittest/commit.go2
-rw-r--r--internal/git/gittest/sha1.go5
-rw-r--r--internal/git/gittest/sha256.go5
3 files changed, 11 insertions, 1 deletions
diff --git a/internal/git/gittest/commit.go b/internal/git/gittest/commit.go
index 2cbb69280..7b4b14440 100644
--- a/internal/git/gittest/commit.go
+++ b/internal/git/gittest/commit.go
@@ -150,7 +150,7 @@ func WriteCommit(t testing.TB, cfg config.Cfg, repoPath string, opts ...WriteCom
tree = writeCommitConfig.treeID.String()
} else if len(parents) == 0 {
// If there are no parents, then we set the root tree to the empty tree.
- tree = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
+ tree = EmptyTreeOID.String()
} else {
tree = parents[0].String() + "^{tree}"
}
diff --git a/internal/git/gittest/sha1.go b/internal/git/gittest/sha1.go
index 7246c400a..631560e63 100644
--- a/internal/git/gittest/sha1.go
+++ b/internal/git/gittest/sha1.go
@@ -4,6 +4,11 @@ package gittest
import "gitlab.com/gitlab-org/gitaly/v15/internal/git"
+const (
+ // EmptyTreeOID is the Git tree object hash that corresponds to an empty tree (directory)
+ EmptyTreeOID = git.EmptyTreeOID
+)
+
var initRepoExtraArgs = []string{}
// NewObjectIDFromHex constructs a new ObjectID from the given hex
diff --git a/internal/git/gittest/sha256.go b/internal/git/gittest/sha256.go
index 5d5bc243a..ad69cd981 100644
--- a/internal/git/gittest/sha256.go
+++ b/internal/git/gittest/sha256.go
@@ -7,6 +7,11 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/git/sha256"
)
+const (
+ // EmptyTreeOID is the Git tree object hash that corresponds to an empty tree (directory)
+ EmptyTreeOID = sha256.EmptyTreeOID
+)
+
var initRepoExtraArgs = []string{"--object-format=sha256"}
// NewObjectIDFromHex constructs a new ObjectID from the given hex