From: Junio C Hamano Date: Fri, 28 Aug 2026 22:57:19 GMT Subject: Re: [PATCH 8/8] checkout: move post_checkout_hook() to checkout.c Message-ID: In-Reply-To: <20260828225206.310500-9-gitster@pobox.com> Junio C Hamano writes: > +int post_checkout_hook(struct commit *old_commit, struct commit *new_commit, > + int changed) > +{ > + struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL; > + > + /* > + * "new_commit" can be NULL when checking out from the index before > + * a commit exists. > + */ > + strvec_pushl(&opt.args, > + oid_to_hex(old_commit ? &old_commit->object.oid : null_oid(the_hash_algo)), > + oid_to_hex(new_commit ? &new_commit->object.oid : null_oid(the_hash_algo)), > + changed ? "1" : "0", > + NULL); > + > + return run_hooks_opt(the_repository, "post-checkout", &opt); > +} Not a very good illustration. We should teach the caller to pass "struct repository *repo" to this function, and then teach this function to learn what hash algorithm to use from the given repository instance. > +/* > + * Run the post-checkout hook. > + */ > +int post_checkout_hook(struct commit *old_commit, struct commit *new_commit, > + int changed); > + > #endif /* CHECKOUT_H */