* [PATCH] index-pack, unpack-objects: restore missing ->init_fn
@ 2025-03-18 11:16 Jensen Huang
2025-03-19 9:32 ` Patrick Steinhardt
0 siblings, 1 reply; 5+ messages in thread
From: Jensen Huang @ 2025-03-18 11:16 UTC (permalink / raw)
To: git; +Cc: Jensen Huang, Junio C Hamano, Patrick Steinhardt
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] index-pack, unpack-objects: restore missing ->init_fn
2025-03-18 11:16 [PATCH] index-pack, unpack-objects: restore missing ->init_fn Jensen Huang
@ 2025-03-19 9:32 ` Patrick Steinhardt
2025-03-19 11:53 ` gtXfined H.
0 siblings, 1 reply; 5+ messages in thread
From: Patrick Steinhardt @ 2025-03-19 9:32 UTC (permalink / raw)
To: Jensen Huang; +Cc: git, Junio C Hamano
On Tue, Mar 18, 2025 at 07:16:10PM +0800, Jensen Huang wrote:
> 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
The change makes sense indeed. I do wonder though: can we maybe improve
`git_hash_clone()` so that it is not required to initialize the context
beforehand?
Thanks!
Patrick
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] index-pack, unpack-objects: restore missing ->init_fn
2025-03-19 9:32 ` Patrick Steinhardt
@ 2025-03-19 11:53 ` gtXfined H.
2025-03-19 13:12 ` Patrick Steinhardt
0 siblings, 1 reply; 5+ messages in thread
From: gtXfined H. @ 2025-03-19 11:53 UTC (permalink / raw)
To: Patrick Steinhardt; +Cc: git, Junio C Hamano
On Wed, Mar 19, 2025 at 5:32 PM Patrick Steinhardt <ps@pks.im> wrote:
>
> On Tue, Mar 18, 2025 at 07:16:10PM +0800, Jensen Huang wrote:
> > 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
>
> The change makes sense indeed. I do wonder though: can we maybe improve
> `git_hash_clone()` so that it is not required to initialize the context
> beforehand?
Thanks for the review!
The idea of improving git_hash_clone() so that it doesn't require
explicit init_fn() calls sounds interesting. However, based on my
current understanding of the code, I'm not sure how to implement this
properly while ensuring it works correctly for all hash
implementations.
If you have any suggestions or guidance on how this could be
approached, I'd appreciate the input!
BR,
Jensen
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] index-pack, unpack-objects: restore missing ->init_fn
2025-03-19 11:53 ` gtXfined H.
@ 2025-03-19 13:12 ` Patrick Steinhardt
2025-03-21 6:11 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Patrick Steinhardt @ 2025-03-19 13:12 UTC (permalink / raw)
To: gtXfined H.; +Cc: git, Junio C Hamano
On Wed, Mar 19, 2025 at 07:53:36PM +0800, gtXfined H. wrote:
> On Wed, Mar 19, 2025 at 5:32 PM Patrick Steinhardt <ps@pks.im> wrote:
> >
> > On Tue, Mar 18, 2025 at 07:16:10PM +0800, Jensen Huang wrote:
> > > 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
> >
> > The change makes sense indeed. I do wonder though: can we maybe improve
> > `git_hash_clone()` so that it is not required to initialize the context
> > beforehand?
>
> Thanks for the review!
> The idea of improving git_hash_clone() so that it doesn't require
> explicit init_fn() calls sounds interesting. However, based on my
> current understanding of the code, I'm not sure how to implement this
> properly while ensuring it works correctly for all hash
> implementations.
> If you have any suggestions or guidance on how this could be
> approached, I'd appreciate the input!
Fair enough. I'm also fine with the patch as-is as it addresses the
issue true to the original spirit. Improving `git_hash_clone()` would be
an extra step that doesn't need to be part of this series, nor does it
have to be you who implements it.
Thanks!
Patrick
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] index-pack, unpack-objects: restore missing ->init_fn
2025-03-19 13:12 ` Patrick Steinhardt
@ 2025-03-21 6:11 ` Junio C Hamano
0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2025-03-21 6:11 UTC (permalink / raw)
To: Patrick Steinhardt; +Cc: gtXfined H., git
Patrick Steinhardt <ps@pks.im> writes:
> Fair enough. I'm also fine with the patch as-is as it addresses the
> issue true to the original spirit. Improving `git_hash_clone()` would be
> an extra step that doesn't need to be part of this series, nor does it
> have to be you who implements it.
Sounds sensible.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-21 6:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 11:16 [PATCH] index-pack, unpack-objects: restore missing ->init_fn Jensen Huang
2025-03-19 9:32 ` Patrick Steinhardt
2025-03-19 11:53 ` gtXfined H.
2025-03-19 13:12 ` Patrick Steinhardt
2025-03-21 6:11 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).