diff options
author | Javi Fontan <jfontan@gmail.com> | 2018-08-14 16:56:29 +0200 |
---|---|---|
committer | Javi Fontan <jfontan@gmail.com> | 2018-08-14 16:56:29 +0200 |
commit | eb2aa9b2c3bf7af93fd261228be1b96e61c52bcf (patch) | |
tree | d4816a29f6460de9d481861cb36c4248212c6270 /plumbing/format | |
parent | 555a6ca02e88279cef421df88a108c2955fcde77 (diff) | |
download | go-git-eb2aa9b2c3bf7af93fd261228be1b96e61c52bcf.tar.gz |
plumbing/packfile: do not compute sha1 for already undeltified objects
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Diffstat (limited to 'plumbing/format')
-rw-r--r-- | plumbing/format/packfile/parser.go | 16 |
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 } |