aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Runxi Yu2025-11-17 00:00:00 +0000
committerGravatar Runxi Yu2025-11-17 00:00:00 +0000
commitf24da2291e8fc5dd6e80047cb45f06ec69a9059c (patch)
treef719b645c0d3c4a16090092c589ccd47c529bf34
parentUpdate perf stats (diff)
signature
Disable per-object validation during reads
In general, git inflates the packed objects and recomputes the object hash before accepting them into hte object database during remote operations. But when simply inflating/parsing the objects for read from the local object store, it does not recompute the hash.
-rw-r--r--loose.go6
-rw-r--r--pack_pack.go8
-rw-r--r--repo.go4
3 files changed, 9 insertions, 9 deletions
diff --git a/loose.go b/loose.go
index 84ebd006..735b7a96 100644
--- a/loose.go
+++ b/loose.go
@@ -70,9 +70,9 @@ func (repo *Repository) looseReadTyped(id Hash) (ObjectType, []byte, error) {
if declaredSize != int64(len(body)) {
return ObjectTypeInvalid, nil, ErrInvalidObject
}
- if !repo.verifyRawObject(raw, id) {
- return ObjectTypeInvalid, nil, ErrInvalidObject
- }
+ // if !repo.verifyRawObject(raw, id) {
+ // return ObjectTypeInvalid, nil, ErrInvalidObject
+ // }
out := append([]byte(nil), body...)
return ty, out, nil
diff --git a/pack_pack.go b/pack_pack.go
index d7b565f5..1ff4a705 100644
--- a/pack_pack.go
+++ b/pack_pack.go
@@ -70,10 +70,10 @@ func (repo *Repository) packReadAt(loc packlocation, want Hash) (StoredObject, e
return nil, err
}
data := body.Bytes()
- if !repo.verifyTypedObject(ty, data, want) {
- body.Release()
- return nil, ErrInvalidObject
- }
+ // if !repo.verifyTypedObject(ty, data, want) {
+ // body.Release()
+ // return nil, ErrInvalidObject
+ // }
obj, err := parseObjectBody(ty, want, data, repo)
body.Release()
return obj, err
diff --git a/repo.go b/repo.go
index 85b4af6b..634351f2 100644
--- a/repo.go
+++ b/repo.go
@@ -159,7 +159,7 @@ func (repo *Repository) computeRawHash(data []byte) Hash {
}
// verifyRawObject verifies a raw object against its expected hash.
-func (repo *Repository) verifyRawObject(buf []byte, want Hash) bool {
+func (repo *Repository) verifyRawObject(buf []byte, want Hash) bool { //nolint:unused
if want.size != repo.hashSize {
return false
}
@@ -167,7 +167,7 @@ func (repo *Repository) verifyRawObject(buf []byte, want Hash) bool {
}
// verifyTypedObject verifies a typed object against its expected hash.
-func (repo *Repository) verifyTypedObject(ty ObjectType, body []byte, want Hash) bool {
+func (repo *Repository) verifyTypedObject(ty ObjectType, body []byte, want Hash) bool { //nolint:unused
if want.size != repo.hashSize {
return false
}