{"thread":{"id":"63150","subject":"[PATCH] index-pack, unpack-objects: restore missing ->init_fn","startedAt":"2025-03-18T11:16:26Z","lastAt":"2025-03-21T06:11:48Z","messageCount":5,"participants":["Jensen Huang","Patrick Steinhardt","gtXfined H.","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"514512","messageId":"20250318111616.113941-1-hmz007@gmail.com","threadId":"63150","inReplyTo":null,"subject":"[PATCH] index-pack, unpack-objects: restore missing ->init_fn","fromName":"Jensen Huang","fromEmail":"hmz007@gmail.com","sentAt":"2025-03-18T11:16:10Z","receivedAt":"2025-03-18T11:16:26Z","isPatch":true,"sender":{"key":"hmz007@gmail.com","avatar":null},"body":"Commit 0578f1e66a (\"global: adapt callers to use generic hash context helpers\")\naccidentally removed `->init_fn`, which is required for OpenSSL 3+ SHA1.\n\nThis fixes the following error on fetch:\n  fatal: fetch-pack: invalid index-pack output\n\nSigned-off-by: Jensen Huang <hmz007@gmail.com>\n---\n builtin/index-pack.c     | 1 +\n builtin/unpack-objects.c | 1 +\n 2 files changed, 2 insertions(+)\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 52cc97d52c..50573ba049 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -1286,6 +1286,7 @@ static void parse_pack_objects(unsigned char *hash)\n \n \t/* Check pack integrity */\n \tflush();\n+\tthe_hash_algo->init_fn(&tmp_ctx);\n \tgit_hash_clone(&tmp_ctx, &input_ctx);\n \tgit_hash_final(hash, &tmp_ctx);\n \tif (!hasheq(fill(the_hash_algo->rawsz), hash, the_repository->hash_algo))\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 8383bcf404..c5a6dca856 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -668,6 +668,7 @@ int cmd_unpack_objects(int argc,\n \tthe_hash_algo->init_fn(&ctx);\n \tunpack_all();\n \tgit_hash_update(&ctx, buffer, offset);\n+\tthe_hash_algo->init_fn(&tmp_ctx);\n \tgit_hash_clone(&tmp_ctx, &ctx);\n \tgit_hash_final_oid(&oid, &tmp_ctx);\n \tif (strict) {\n-- \n2.49.0-1\n\n"},{"id":"514626","messageId":"Z9qPMvclpdEIjQ3l@pks.im","threadId":"63150","inReplyTo":"20250318111616.113941-1-hmz007@gmail.com","subject":"Re: [PATCH] index-pack, unpack-objects: restore missing ->init_fn","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-19T09:32:34Z","receivedAt":"2025-03-19T09:32:38Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Mar 18, 2025 at 07:16:10PM +0800, Jensen Huang wrote:\n> Commit 0578f1e66a (\"global: adapt callers to use generic hash context helpers\")\n> accidentally removed `->init_fn`, which is required for OpenSSL 3+ SHA1.\n> \n> This fixes the following error on fetch:\n>   fatal: fetch-pack: invalid index-pack output\n\nThe change makes sense indeed. I do wonder though: can we maybe improve\n`git_hash_clone()` so that it is not required to initialize the context\nbeforehand?\n\nThanks!\n\nPatrick\n"},{"id":"514633","messageId":"CAGr7CZnNdTsUuJU+Z8HBX6wQu_HF-faDPPhuLx7u-Y=TGeop+w@mail.gmail.com","threadId":"63150","inReplyTo":"Z9qPMvclpdEIjQ3l@pks.im","subject":"Re: [PATCH] index-pack, unpack-objects: restore missing ->init_fn","fromName":"gtXfined H.","fromEmail":"hmz007@gmail.com","sentAt":"2025-03-19T11:53:36Z","receivedAt":"2025-03-19T11:53:49Z","isPatch":true,"sender":{"key":"hmz007@gmail.com","avatar":null},"body":"On Wed, Mar 19, 2025 at 5:32 PM Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Tue, Mar 18, 2025 at 07:16:10PM +0800, Jensen Huang wrote:\n> > Commit 0578f1e66a (\"global: adapt callers to use generic hash context helpers\")\n> > accidentally removed `->init_fn`, which is required for OpenSSL 3+ SHA1.\n> >\n> > This fixes the following error on fetch:\n> >   fatal: fetch-pack: invalid index-pack output\n>\n> The change makes sense indeed. I do wonder though: can we maybe improve\n> `git_hash_clone()` so that it is not required to initialize the context\n> beforehand?\n\nThanks for the review!\nThe idea of improving git_hash_clone() so that it doesn't require\nexplicit init_fn() calls sounds interesting. However, based on my\ncurrent understanding of the code, I'm not sure how to implement this\nproperly while ensuring it works correctly for all hash\nimplementations.\nIf you have any suggestions or guidance on how this could be\napproached, I'd appreciate the input!\n\nBR,\nJensen\n"},{"id":"514635","messageId":"Z9rC0VCbh8Noaq4e@pks.im","threadId":"63150","inReplyTo":"CAGr7CZnNdTsUuJU+Z8HBX6wQu_HF-faDPPhuLx7u-Y=TGeop+w@mail.gmail.com","subject":"Re: [PATCH] index-pack, unpack-objects: restore missing ->init_fn","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-03-19T13:12:49Z","receivedAt":"2025-03-19T13:12:55Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Mar 19, 2025 at 07:53:36PM +0800, gtXfined H. wrote:\n> On Wed, Mar 19, 2025 at 5:32 PM Patrick Steinhardt <ps@pks.im> wrote:\n> >\n> > On Tue, Mar 18, 2025 at 07:16:10PM +0800, Jensen Huang wrote:\n> > > Commit 0578f1e66a (\"global: adapt callers to use generic hash context helpers\")\n> > > accidentally removed `->init_fn`, which is required for OpenSSL 3+ SHA1.\n> > >\n> > > This fixes the following error on fetch:\n> > >   fatal: fetch-pack: invalid index-pack output\n> >\n> > The change makes sense indeed. I do wonder though: can we maybe improve\n> > `git_hash_clone()` so that it is not required to initialize the context\n> > beforehand?\n> \n> Thanks for the review!\n> The idea of improving git_hash_clone() so that it doesn't require\n> explicit init_fn() calls sounds interesting. However, based on my\n> current understanding of the code, I'm not sure how to implement this\n> properly while ensuring it works correctly for all hash\n> implementations.\n> If you have any suggestions or guidance on how this could be\n> approached, I'd appreciate the input!\n\nFair enough. I'm also fine with the patch as-is as it addresses the\nissue true to the original spirit. Improving `git_hash_clone()` would be\nan extra step that doesn't need to be part of this series, nor does it\nhave to be you who implements it.\n\nThanks!\n\nPatrick\n"},{"id":"514820","messageId":"xmqq4izmx68u.fsf@gitster.g","threadId":"63150","inReplyTo":"Z9rC0VCbh8Noaq4e@pks.im","subject":"Re: [PATCH] index-pack, unpack-objects: restore missing ->init_fn","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-03-21T06:11:45Z","receivedAt":"2025-03-21T06:11:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> Fair enough. I'm also fine with the patch as-is as it addresses the\n> issue true to the original spirit. Improving `git_hash_clone()` would be\n> an extra step that doesn't need to be part of this series, nor does it\n> have to be you who implements it.\n\nSounds sensible.\n"}]}