"Elijah Newren via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:
> - if (whence != FROM_COMMIT) {
> - if (whence == FROM_MERGE)
> - die(_("cannot do a partial commit during a merge."));
> - else if (is_from_cherry_pick(whence))
> - die(_("cannot do a partial commit during a cherry-pick."));
> + switch (sequencer_ongoing_operation(the_repository, whence)) {
> + case ONGOING_NONE:
> + break;
> + case ONGOING_MERGE:
> + die(_("cannot do a partial commit during a merge."));
> + case ONGOING_CHERRY_PICK:
> + die(_("cannot do a partial commit during a cherry-pick."));
> + case ONGOING_REBASE_EMPTY:
> + /*
> + * A pick that became empty is not a conflict, and creating
> + * a new commit (partial or not) poses no problem.
> + */
> + break;
> + case ONGOING_REVERT:
> + die(_("cannot do a partial commit during a revert."));
> + case ONGOING_AM:
> + die(_("cannot do a partial commit during an am session."));
> + case ONGOING_REBASE_CONFLICT:
> + die(_("cannot do a partial commit while resolving conflicts during a rebase."));
> }
Looks quite thorough.
Deliberate ommission of "default:" is a plus ;-)