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>

Johannes Schindelin committed Aug 26, 2016 at 15:47 UTC b9b946d4a4e9e30bc0dba9ce3ff81ab3d3666632
1 file changed +5 -4
sequencer.c
+5 -4
@@ -1063,10 +1063,11 @@ int sequencer_pick_revisions(struct replay_opts *opts)
1063 if (!get_sha1(name, sha1)) {
1064 if (!lookup_commit_reference_gently(sha1, 1)) {
1065 enum object_type type = sha1_object_info(sha1, NULL);
1066 - die(_("%s: can't cherry-pick a %s"), name, typename(type));
1066 + return error(_("%s: can't cherry-pick a %s"),
1067 + name, typename(type));
1068 }
1069 } else
1069 - die(_("%s: bad revision"), name);
1070 + return error(_("%s: bad revision"), name);
1071 }
1072
1073 /*
@@ -1082,10 +1083,10 @@ int sequencer_pick_revisions(struct replay_opts *opts)
1083 !opts->revs->cmdline.rev->flags) {
1084 struct commit *cmit;
1085 if (prepare_revision_walk(opts->revs))
1085 - die(_("revision walk setup failed"));
1086 + return error(_("revision walk setup failed"));
1087 cmit = get_revision(opts->revs);
1088 if (!cmit || get_revision(opts->revs))
1088 - die("BUG: expected exactly one commit from walk");
1089 + return error("BUG: expected exactly one commit from walk");
1090 return single_pick(cmit, opts);
1091 }
1092