Re: [PATCH 8/8] checkout: move post_checkout_hook() to checkout.c
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 28, 2026, 22:57 UTC
- Message-ID
- <xmqq7bl93lbk.fsf@gitster.g>
- In-Reply-To
- <20260828225206.310500-9-gitster@pobox.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 17 quoted lines
> +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.
Show 7 quoted lines
> +/* > + * Run the post-checkout hook. > + */ > +int post_checkout_hook(struct commit *old_commit, struct commit *new_commit, > + int changed); > + > #endif /* CHECKOUT_H */