]> git.99rst.org Git - git.git/commit
hash algorithms: use size_t for section lengths
authorPhilip Oakley <redacted>
Tue, 16 Jun 2026 14:49:54 +0000 (14:49 +0000)
committerJunio C Hamano <redacted>
Tue, 16 Jun 2026 16:02:33 +0000 (09:02 -0700)
commit58823d431061b82a9cd02a1623aff6fe93a51446
treefa12917dd55d3349c4891fce1bdc73240de0a800
parenta39fda4fca37c1b8700ccfe0f9d0194445373b97
hash algorithms: use size_t for section lengths

Continue walking the code path for the >4GB `hash-object --literally`
test to the hash algorithm step for LLP64 systems.

This patch lets the SHA1DC code use `size_t`, making it compatible with
LLP64 data models (as used e.g. by Windows).

The interested reader of this patch will note that we adjust the
signature of the `git_SHA1DCUpdate()` function without updating _any_
call site. This certainly puzzled at least one reviewer already, so here
is an explanation:

This function is never called directly, but always via the macro
`platform_SHA1_Update`, which is usually called via the macro
`git_SHA1_Update`. However, we never call `git_SHA1_Update()` directly
in `struct git_hash_algo`. Instead, we call `git_hash_sha1_update()`,
which is defined thusly:

    static void git_hash_sha1_update(git_hash_ctx *ctx,
                                     const void *data, size_t len)
    {
        git_SHA1_Update(&ctx->sha1, data, len);
    }

i.e. it contains an implicit downcast from `size_t` to `unsigned long`
(before this here patch). With this patch, there is no downcast anymore.

With this patch, finally, the t1007-hash-object.sh "files over 4GB hash
literally" test case is fixed.

Signed-off-by: Philip Oakley <redacted>
Signed-off-by: Johannes Schindelin <redacted>
Signed-off-by: Junio C Hamano <redacted>
object-file.c
sha1dc_git.c
sha1dc_git.h
t/t1007-hash-object.sh
git clone https://git.99rst.org/PROJECT