sequencer: lib'ify walk_revs_populate_todo()

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() is the only caller of walk_revs_populate_todo(), and it already returns errors appropriately, so its caller 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 walk_revs_populate_todo() 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 Sep 9, 2016 at 16:37 UTC 34b0528b735cd22e5600576c10904dff262b8332
1 file changed +6 -4
sequencer.c
+6 -4
@@ -809,17 +809,19 @@ static void read_populate_opts(struct replay_opts **opts_ptr)
809 die(_("Malformed options sheet: %s"), git_path_opts_file());
810 }
811
812 -static void walk_revs_populate_todo(struct commit_list **todo_list,
812 +static int walk_revs_populate_todo(struct commit_list **todo_list,
813 struct replay_opts *opts)
814 {
815 struct commit *commit;
816 struct commit_list **next;
817
818 - prepare_revs(opts);
818 + if (prepare_revs(opts))
819 + return -1;
820
821 next = todo_list;
822 while ((commit = get_revision(opts->revs)))
823 next = commit_list_append(commit, next);
824 + return 0;
825 }
826
827 static int create_seq_dir(void)
@@ -1102,8 +1104,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)
1104 * progress
1105 */
1106
1105 - walk_revs_populate_todo(&todo_list, opts);
1106 - if (create_seq_dir() < 0)
1107 + if (walk_revs_populate_todo(&todo_list, opts) ||
1108 + create_seq_dir() < 0)
1109 return -1;
1110 if (get_sha1("HEAD", sha1) && (opts->action == REPLAY_REVERT))
1111 return error(_("Can't revert as initial commit"));