From: Junio C Hamano Date: Fri, 03 Jan 2025 16:25:25 GMT Subject: Re: [PATCH 02/10] builtin/fast-import: fix segfault with unsafe SHA1 Message-ID: In-Reply-To: Patrick Steinhardt writes: > I think the ideal state would be if the hashing function used was stored > as part of `struct git_hash_ctx`. So the flow basically becomes for > example: > > ``` > struct git_hash_ctx ctx; > struct object_id oid; > > git_hash_sha1_init(&ctx); > git_hash_update(&ctx, data); > git_hash_final_oid(&oid, &ctx); > ``` > > Note how the intermediate calls don't need to know which hash function > you used to initialize the `struct git_hash_ctx` -- the structure itself > should remember what it has been initilized with and do the right thing. Yup, that sounds perfect.