diff options
author | KN4CK3R <KN4CK3R@users.noreply.github.com> | 2021-05-14 15:12:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-14 14:12:11 +0100 |
commit | df72cf62111114237324857d1393d31312bccca9 (patch) | |
tree | cf9701bc068822d93e61a1ab0f32cbf197d85b9e /modules/git/batch_reader.go | |
parent | 1a5659943eba747b05efe564ac57a942b0424f91 (diff) | |
download | gitea-df72cf62111114237324857d1393d31312bccca9.tar.gz gitea-df72cf62111114237324857d1393d31312bccca9.zip |
Fix LFS commit finder not working (#15856)
* Create a copy of the sha bytes.
Co-authored-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/git/batch_reader.go')
-rw-r--r-- | modules/git/batch_reader.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/git/batch_reader.go b/modules/git/batch_reader.go index 3d3a6916f5..d6ee0ce8e0 100644 --- a/modules/git/batch_reader.go +++ b/modules/git/batch_reader.go @@ -186,17 +186,18 @@ headerLoop: // constant hextable to help quickly convert between 20byte and 40byte hashes const hextable = "0123456789abcdef" -// To40ByteSHA converts a 20-byte SHA in a 40-byte slice into a 40-byte sha in place -// without allocations. This is at least 100x quicker that hex.EncodeToString -// NB This requires that sha is a 40-byte slice -func To40ByteSHA(sha []byte) []byte { +// To40ByteSHA converts a 20-byte SHA into a 40-byte sha. Input and output can be the +// same 40 byte slice to support in place conversion without allocations. +// This is at least 100x quicker that hex.EncodeToString +// NB This requires that out is a 40-byte slice +func To40ByteSHA(sha, out []byte) []byte { for i := 19; i >= 0; i-- { v := sha[i] vhi, vlo := v>>4, v&0x0f shi, slo := hextable[vhi], hextable[vlo] - sha[i*2], sha[i*2+1] = shi, slo + out[i*2], out[i*2+1] = shi, slo } - return sha + return out } // ParseTreeLineSkipMode reads an entry from a tree in a cat-file --batch stream |