Re: [PATCH v2 05/14] sequencer: lib'ify do_pick_commit()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 29, 2016, 20:32 UTC
- Message-ID
- <xmqqbn0b9uyx.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <39d03662fc6ea81d737c0650bb9b7292e812ae02.1472219214.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
Show 30 quoted lines
> Instead of dying there, let the caller high up in the callchain notice
> the error and handle it (by dying, still).
>
> The only two callers of do_pick_commit(), pick_commits() and
> single_pick() already check the return value and pass it on to their
> callers, so their callers must be already prepared to handle error
> returns, and with this step, we make it notice an error return from
> this function.
>
> So this is a safe conversion to make do_pick_commit() callable from
> new callers that want it not to die, without changing the external
> behaviour of anything existing.
>
> While at it, remove the superfluous space.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> sequencer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index f6cdf65..7eef512 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -464,7 +464,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
> * to work on.
> */
> if (write_cache_as_tree(head, 0, NULL))
> - die (_("Your index file is unmerged."));
> + return error(_("Your index file is unmerged."));Makes sense.
do_pick_commit() still calls fast_forward_to(), which was silently half libified in 3/14 but can still die in checkout_fast_forward(), though.