public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Jensen Huang <hmz007@gmail.com>
To: git@vger.kernel.org
Cc: Jensen Huang <hmz007@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Patrick Steinhardt <ps@pks.im>
Subject: [PATCH] index-pack, unpack-objects: restore missing ->init_fn
Date: Tue, 18 Mar 2025 19:16:10 +0800	[thread overview]
Message-ID: <20250318111616.113941-1-hmz007@gmail.com> (raw)

Commit 0578f1e66a ("global: adapt callers to use generic hash context helpers")
accidentally removed `->init_fn`, which is required for OpenSSL 3+ SHA1.

This fixes the following error on fetch:
  fatal: fetch-pack: invalid index-pack output

Signed-off-by: Jensen Huang <hmz007@gmail.com>
---
 builtin/index-pack.c     | 1 +
 builtin/unpack-objects.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 52cc97d52c..50573ba049 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1286,6 +1286,7 @@ static void parse_pack_objects(unsigned char *hash)
 
 	/* Check pack integrity */
 	flush();
+	the_hash_algo->init_fn(&tmp_ctx);
 	git_hash_clone(&tmp_ctx, &input_ctx);
 	git_hash_final(hash, &tmp_ctx);
 	if (!hasheq(fill(the_hash_algo->rawsz), hash, the_repository->hash_algo))
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 8383bcf404..c5a6dca856 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -668,6 +668,7 @@ int cmd_unpack_objects(int argc,
 	the_hash_algo->init_fn(&ctx);
 	unpack_all();
 	git_hash_update(&ctx, buffer, offset);
+	the_hash_algo->init_fn(&tmp_ctx);
 	git_hash_clone(&tmp_ctx, &ctx);
 	git_hash_final_oid(&oid, &tmp_ctx);
 	if (strict) {
-- 
2.49.0-1


             reply	other threads:[~2025-03-18 11:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18 11:16 Jensen Huang [this message]
2025-03-19  9:32 ` [PATCH] index-pack, unpack-objects: restore missing ->init_fn Patrick Steinhardt
2025-03-19 11:53   ` gtXfined H.
2025-03-19 13:12     ` Patrick Steinhardt
2025-03-21  6:11       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250318111616.113941-1-hmz007@gmail.com \
    --to=hmz007@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox