Re: [PATCH v2 11/14] reset_head(): take struct rebase_head_opts
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 9, 2021, 19:31 UTC
- Message-ID
- <xmqq7dcdr2x5.fsf@gitster.g>
- In-Reply-To
- <24b0566aba5d8800d209261a14aca4d872af8027.1638975482.git.gitgitgadget@gmail.com>
"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 9 quoted lines
> From: Phillip Wood <phillip.wood@dunelm.org.uk> > > This function takes a confusingly large number of parameters which > makes it difficult to remember which order to pass them in. The > following commits will add a couple more parameters which makes the > problem worse. To address this change the function to take a struct of > options. Using a struct means that it is no longer necessary to > remember which order to pass the parameters in and anyone reading the > code can easily see which value is passed to each parameter.
OK. The documentation for members in the structure will serve as the user manual for the reset_head() function. Good.
Show 17 quoted lines
> +struct reset_head_opts {
> + /*
> + * The commit to checkout/reset to. Defaults to HEAD.
> + */
> + const struct object_id *oid;
> + /*
> + * Optional branch to switch to.
> + */
> + const char *branch;
> + /*
> + * Flags defined above.
> + */
> + unsigned flags;
> + /*
> + * Optional reflog message for HEAD, if this omitted but oid or branch
> + * are given then default_reflog_action must be given.
> + */If we can enforce such a requirement in reset_head() implementation with "if (condition) BUG(...)", we should do so to catch mistakes.
Thanks. Looking good.