]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/submodule-helper-avoid-zu'
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Jul 2026 16:08:58 +0000 (09:08 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Jul 2026 16:08:58 +0000 (09:08 -0700)
An accidental use of the '%zu' format specifier in 'git
submodule--helper' has been corrected to use 'PRIuMAX' and cast the
value to 'uintmax_t' to avoid portability issues.

* jc/submodule-helper-avoid-zu:
  submodule--helper: avoid use of %zu for now

1  2 
builtin/submodule--helper.c

index 2b3c9762afec0ad99cbfe196c2e421f972124938,49463b7d2b568dcc9b6d79514a8fbba34a49ff06..65222706ea1188728df0dc9962fd56c158862a8d
@@@ -549,12 -549,13 +549,13 @@@ static void create_default_gitdir_confi
        }
  
        /* Case 2.4: If all the above failed, try a hash of the name as a last resort */
-       header_len = snprintf(header, sizeof(header), "blob %zu", strlen(submodule_name));
+       header_len = snprintf(header, sizeof(header),
+                             "blob %"PRIuMAX, (uintmax_t)strlen(submodule_name));
 -      the_hash_algo->init_fn(&ctx);
 -      the_hash_algo->update_fn(&ctx, header, header_len);
 -      the_hash_algo->update_fn(&ctx, "\0", 1);
 -      the_hash_algo->update_fn(&ctx, submodule_name, strlen(submodule_name));
 -      the_hash_algo->final_fn(raw_name_hash, &ctx);
 +      git_hash_init(&ctx, the_hash_algo);
 +      git_hash_update(&ctx, header, header_len);
 +      git_hash_update(&ctx, "\0", 1);
 +      git_hash_update(&ctx, submodule_name, strlen(submodule_name));
 +      git_hash_final(raw_name_hash, &ctx);
        hash_to_hex_algop_r(hex_name_hash, raw_name_hash, the_hash_algo);
        strbuf_reset(&gitdir_path);
        repo_git_path_append(the_repository, &gitdir_path, "modules/%s", hex_name_hash);