aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavi Fontan <jfontan@gmail.com>2018-08-14 16:56:29 +0200
committerJavi Fontan <jfontan@gmail.com>2018-08-14 16:56:29 +0200
commiteb2aa9b2c3bf7af93fd261228be1b96e61c52bcf (patch)
treed4816a29f6460de9d481861cb36c4248212c6270
parent555a6ca02e88279cef421df88a108c2955fcde77 (diff)
downloadgo-git-eb2aa9b2c3bf7af93fd261228be1b96e61c52bcf.tar.gz
plumbing/packfile: do not compute sha1 for already undeltified objects
Signed-off-by: Javi Fontan <jfontan@gmail.com>
-rw-r--r--plumbing/format/packfile/parser.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/plumbing/format/packfile/parser.go b/plumbing/format/packfile/parser.go
index 3a9c4d7..28582b5 100644
--- a/plumbing/format/packfile/parser.go
+++ b/plumbing/format/packfile/parser.go
@@ -423,14 +423,16 @@ func applyPatchBase(ota *objectInfo, data, base []byte) ([]byte, error) {
return nil, err
}
- ota.Type = ota.Parent.Type
- sha1, err := getSHA1(ota.Type, patched)
- if err != nil {
- return nil, err
- }
+ if ota.SHA1 == plumbing.ZeroHash {
+ ota.Type = ota.Parent.Type
+ sha1, err := getSHA1(ota.Type, patched)
+ if err != nil {
+ return nil, err
+ }
- ota.SHA1 = sha1
- ota.Length = int64(len(patched))
+ ota.SHA1 = sha1
+ ota.Length = int64(len(patched))
+ }
return patched, nil
}