]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch-pack: use unsigned int for hash_algo variable
authorPablo Sabater <pabloosabaterr@gmail.com>
Fri, 24 Jul 2026 10:54:16 +0000 (12:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Jul 2026 15:46:59 +0000 (08:46 -0700)
hash_algo_by_name() returns unsigned int, but it is stored in
hash_algo variable as int. This goes unnoticed because of:

DISABLE_SIGN_COMPARE_WARNINGS

On 'fetch-pack.c'

On a subsequent commit this function will be moved to 'connect.c' that
would notice this.

Change hash_algo variable type to match its return type, also make it
const because they are never modified.

Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fetch-pack.c

index 65ebfec09fc62df11846d7be1a8740262e48b2b4..f1e64160fc92a6f1acbfa13d1103b78073e789c6 100644 (file)
@@ -1397,7 +1397,7 @@ static void write_fetch_command_and_capabilities(struct strbuf *req_buf,
        }
 
        if (server_feature_v2("object-format", &hash_name)) {
-               int hash_algo = hash_algo_by_name(hash_name);
+               const unsigned int hash_algo = hash_algo_by_name(hash_name);
                if (hash_algo_by_ptr(the_hash_algo) != hash_algo)
                        die(_("mismatched algorithms: client %s; server %s"),
                            the_hash_algo->name, hash_name);