Re: [PATCH 05/31] pack-bitmap: switch hard-coded constants to the_hash_algo
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Feb 12, 2019, 11:13 UTC
- Message-ID
- <87va1pjm4d.fsf@evledraar.gmail.com>
- In-Reply-To
- <20190212012256.1005924-6-sandals@crustytoothpaste.net>
On Tue, Feb 12 2019, brian m. carlson wrote:
Show 29 quoted lines
> Switch two hard-coded uses of 20 to references to the_hash_algo.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
> pack-bitmap.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/pack-bitmap.c b/pack-bitmap.c
> index 6d6fa68563..603492c237 100644
> --- a/pack-bitmap.c
> +++ b/pack-bitmap.c
> @@ -138,7 +138,7 @@ static int load_bitmap_header(struct bitmap_index *index)
> {
> struct bitmap_disk_header *header = (void *)index->map;
>
> - if (index->map_size < sizeof(*header) + 20)
> + if (index->map_size < sizeof(*header) + the_hash_algo->rawsz)
> return error("Corrupted bitmap index (missing header data)");
>
> if (memcmp(header->magic, BITMAP_IDX_SIGNATURE, sizeof(BITMAP_IDX_SIGNATURE)) != 0)
> @@ -157,7 +157,7 @@ static int load_bitmap_header(struct bitmap_index *index)
> "(Git requires BITMAP_OPT_FULL_DAG)");
>
> if (flags & BITMAP_OPT_HASH_CACHE) {
> - unsigned char *end = index->map + index->map_size - 20;
> + unsigned char *end = index->map + index->map_size - the_hash_algo->rawsz;
> index->hashes = ((uint32_t *)end) - index->pack->num_objects;
> }
> }Similarly to my other comments upthread, what happens in a repo where we have a SHA-1 bitmap file & a SHA-1<->SHA-256 mapping?