Re: [PATCH 02/10] builtin/fast-import: fix segfault with unsafe SHA1
Patrick Steinhardt <ps@pks.im> writes:
Show 16 quoted lines
> 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.