Re: [PATCH 31/44] connect: parse v2 refs with correct hash algorithm
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- May 17, 2020, 22:37 UTC
- Message-ID
- <20200517223717.GL6362@camp.crustytoothpaste.net>
- In-Reply-To
- <CAN0heSpq-t1E6CBsLiVDUE8NYB2ES916MR=d99eug9U=vdOLHQ@mail.gmail.com>
On 2020-05-16 at 11:14:16, Martin Ågren wrote:
Show 21 quoted lines
> On Wed, 13 May 2020 at 02:58, brian m. carlson > <sandals@crustytoothpaste.net> wrote: > > > > When using protocol v2, we need to know what hash algorithm is used by > > the remote end. See if the server has sent us an object-format > > capability, and if so, use it to determine the hash algorithm in use and > > set that value in the packet reader. Parse the refs using this > > algorithm. > > > > Note that we use memcpy instead of oidcpy for copying values, since > > oidcpy is intentionally limited to the current hash algorithm length, > > and the copy will be too short if the server side uses SHA-256 but the > > client side has not had a repository set up (and therefore defaults to > > SHA-1). > > > - oidcpy(&ref->old_oid, &old_oid); > > + memcpy(ref->old_oid.hash, old_oid.hash, reader->hash_algo->rawsz); > > Might an `oidcpy_algop()` prove useful over time? > > oidcpy_algop(&ref->old_oid, &old_oid, reader->hash_algo);
I think I can just omit this chunk, because oidcpy now copies the entire struct for speed.
-- brian m. carlson: Houston, Texas, US OpenPGP: https://keybase.io/bk2204