summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2016-08-26 13:47:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-08-29 20:15:14 (GMT)
commitb9b946d4a4e9e30bc0dba9ce3ff81ab3d3666632 (patch)
tree11fca34e84d0682daad778ae6f4f7481cdcb88a3 /sequencer.c
parentd5cb9cbd64165153a318e1049f8bf14b09a16b11 (diff)
downloadgit-b9b946d4a4e9e30bc0dba9ce3ff81ab3d3666632.zip
git-b9b946d4a4e9e30bc0dba9ce3ff81ab3d3666632.tar.gz
git-b9b946d4a4e9e30bc0dba9ce3ff81ab3d3666632.tar.bz2
sequencer: lib'ify sequencer_pick_revisions()
Instead of dying there, let the caller high up in the callchain notice the error and handle it (by dying, still). The function sequencer_pick_revisions() has only two callers, cmd_revert() and cmd_cherry_pick(), both of which check the return value and react appropriately upon errors. So this is a safe conversion to make sequencer_pick_revisions() 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.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sequencer.c b/sequencer.c
index 3804fa9..76b1c52 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1063,10 +1063,11 @@ int sequencer_pick_revisions(struct replay_opts *opts)
if (!get_sha1(name, sha1)) {
if (!lookup_commit_reference_gently(sha1, 1)) {
enum object_type type = sha1_object_info(sha1, NULL);
- die(_("%s: can't cherry-pick a %s"), name, typename(type));
+ return error(_("%s: can't cherry-pick a %s"),
+ name, typename(type));
}
} else
- die(_("%s: bad revision"), name);
+ return error(_("%s: bad revision"), name);
}
/*
@@ -1082,10 +1083,10 @@ int sequencer_pick_revisions(struct replay_opts *opts)
!opts->revs->cmdline.rev->flags) {
struct commit *cmit;
if (prepare_revision_walk(opts->revs))
- die(_("revision walk setup failed"));
+ return error(_("revision walk setup failed"));
cmit = get_revision(opts->revs);
if (!cmit || get_revision(opts->revs))
- die("BUG: expected exactly one commit from walk");
+ return error("BUG: expected exactly one commit from walk");
return single_pick(cmit, opts);
}