diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2016-08-26 15:47:14 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-08-29 13:15:14 -0700 |
commit | dbfad033d443f27c5579bbb67bd14243b0cbaba6 (patch) | |
tree | c7e7011f52be924b674bc782e7a7cd560704a3c9 /sequencer.c | |
parent | b9b946d4a4e9e30bc0dba9ce3ff81ab3d3666632 (diff) | |
download | git-dbfad033d443f27c5579bbb67bd14243b0cbaba6.tar.gz |
sequencer: do not die() in do_pick_commit()
Instead of dying there, let the caller high up in the callchain
notice the error and handle it (by dying, still).
The eventual caller of do_pick_commit() is sequencer_pick_revisions(),
which already relays a reported error from its helper functions
(including this one), and both of its two callers know how to react to
a negative return correctly.
So this makes do_pick_commit() callable from new callers that want it
not to die, without changing the external behaviour of anything
existing.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sequencer.c b/sequencer.c index 76b1c52f75..baf6b40e7a 100644 --- a/sequencer.c +++ b/sequencer.c @@ -585,12 +585,14 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts) * However, if the merge did not even start, then we don't want to * write it at all. */ - if (opts->action == REPLAY_PICK && !opts->no_commit && (res == 0 || res == 1)) - update_ref(NULL, "CHERRY_PICK_HEAD", commit->object.oid.hash, NULL, - REF_NODEREF, UPDATE_REFS_DIE_ON_ERR); - if (opts->action == REPLAY_REVERT && ((opts->no_commit && res == 0) || res == 1)) - update_ref(NULL, "REVERT_HEAD", commit->object.oid.hash, NULL, - REF_NODEREF, UPDATE_REFS_DIE_ON_ERR); + if (opts->action == REPLAY_PICK && !opts->no_commit && (res == 0 || res == 1) && + update_ref(NULL, "CHERRY_PICK_HEAD", commit->object.oid.hash, NULL, + REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) + res = -1; + if (opts->action == REPLAY_REVERT && ((opts->no_commit && res == 0) || res == 1) && + update_ref(NULL, "REVERT_HEAD", commit->object.oid.hash, NULL, + REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) + res = -1; if (res) { error(opts->action == REPLAY_REVERT |