builtin/receive-pack: replace sha1_to_hex

Since sha1_to_hex is limited to SHA-1, replace it with hash_to_hex. Rename several variables to indicate that they can contain any hash. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Aug 18, 2019 at 20:04 UTC fc06be3b7f065d197fd484098f517fa9d19c9d2b
1 file changed +4 -4
builtin/receive-pack.c
+4 -4
@@ -466,7 +466,7 @@ static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp)
466 strbuf_release(&buf);
467
468 /* RFC 2104 5. HMAC-SHA1-80 */
469 - strbuf_addf(&buf, "%"PRItime"-%.*s", stamp, (int)the_hash_algo->hexsz, sha1_to_hex(hash));
469 + strbuf_addf(&buf, "%"PRItime"-%.*s", stamp, (int)the_hash_algo->hexsz, hash_to_hex(hash));
470 return strbuf_detach(&buf, NULL);
471 }
472
@@ -968,7 +968,7 @@ static const char *push_to_deploy(unsigned char *sha1,
968 if (run_command(&child))
969 return "Working directory has staged changes";
970
971 - read_tree[3] = sha1_to_hex(sha1);
971 + read_tree[3] = hash_to_hex(sha1);
972 child_process_init(&child);
973 child.argv = read_tree;
974 child.env = env->argv;
@@ -985,13 +985,13 @@ static const char *push_to_deploy(unsigned char *sha1,
985
986 static const char *push_to_checkout_hook = "push-to-checkout";
987
988 -static const char *push_to_checkout(unsigned char *sha1,
988 +static const char *push_to_checkout(unsigned char *hash,
989 struct argv_array *env,
990 const char *work_tree)
991 {
992 argv_array_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
993 if (run_hook_le(env->argv, push_to_checkout_hook,
994 - sha1_to_hex(sha1), NULL))
994 + hash_to_hex(hash), NULL))
995 return "push-to-checkout hook declined";
996 else
997 return NULL;