Re: [PATCH v2 04/36] cache-tree: convert remnants to struct object_id
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Feb 26, 2018, 11:15 UTC
- Message-ID
- <CACsJy8BxrsrGf7vo39ycwAAgbmXKEz_Sx3Ksb3prL2pZwW07ag@mail.gmail.com>
- In-Reply-To
- <20180225211212.477570-5-sandals@crustytoothpaste.net>
On Mon, Feb 26, 2018 at 4:11 AM, brian m. carlson <sandals@crustytoothpaste.net> wrote:
Show 22 quoted lines
> @@ -465,7 +465,7 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,
> #endif
>
> if (0 <= it->entry_count) {
> - strbuf_add(buffer, it->oid.hash, 20);
> + strbuf_add(buffer, it->oid.hash, the_hash_algo->rawsz);
> }
> for (i = 0; i < it->subtree_nr; i++) {
> struct cache_tree_sub *down = it->down[i];
> @@ -520,11 +520,11 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
> goto free_return;
> buf++; size--;
> if (0 <= it->entry_count) {
> - if (size < 20)
> + if (size < the_hash_algo->rawsz)
> goto free_return;
> hashcpy(it->oid.hash, (const unsigned char*)buf);
> - buf += 20;
> - size -= 20;
> + buf += the_hash_algo->rawsz;
> + size -= the_hash_algo->rawsz;
> }This looks a bit strange that everything else is now with hash abstraction, except that it->oid is still copied with hashcpy(). But I guess we don't have an equivalent for that function yet..
But since it->oid.hash is copied to buffer with strbuf_add() in the top chunk, maybe we can do memcpy() here with the_hash_algo ->rawsz too?
-- Duy