1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-28 10:26:25 +02:00

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>
This commit is contained in:
Johannes Schindelin 2016-09-09 16:37:15 +02:00 committed by Junio C Hamano
parent f74087f6ed
commit 34b0528b73

View File

@ -809,17 +809,19 @@ static void read_populate_opts(struct replay_opts **opts_ptr)
die(_("Malformed options sheet: %s"), git_path_opts_file());
}
static void walk_revs_populate_todo(struct commit_list **todo_list,
static int walk_revs_populate_todo(struct commit_list **todo_list,
struct replay_opts *opts)
{
struct commit *commit;
struct commit_list **next;
prepare_revs(opts);
if (prepare_revs(opts))
return -1;
next = todo_list;
while ((commit = get_revision(opts->revs)))
next = commit_list_append(commit, next);
return 0;
}
static int create_seq_dir(void)
@ -1102,8 +1104,8 @@ int sequencer_pick_revisions(struct replay_opts *opts)
* progress
*/
walk_revs_populate_todo(&todo_list, opts);
if (create_seq_dir() < 0)
if (walk_revs_populate_todo(&todo_list, opts) ||
create_seq_dir() < 0)
return -1;
if (get_sha1("HEAD", sha1) && (opts->action == REPLAY_REVERT))
return error(_("Can't revert as initial commit"));