Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2016-09-09 17:37:24 +0300
committerJunio C Hamano <gitster@pobox.com>2016-09-09 21:24:52 +0300
commit0ae42a038da1f63a5b090b70502087817cc54f5d (patch)
treeb7fc351c08b1b56598bb2fc231181ac3c7e921f6 /sequencer.c
parent0d9c6dc9ec316c5b117ee53b44d346349bd8b818 (diff)
sequencer: lib'ify read_populate_todo()
Instead of dying there, let the caller high up in the callchain notice the error and handle it (by dying, still). The only caller of read_populate_todo(), sequencer_continue() can already return errors, 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 read_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>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sequencer.c b/sequencer.c
index 631b75dabe..c73cdfdac1 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -748,7 +748,7 @@ static int parse_insn_buffer(char *buf, struct commit_list **todo_list,
return 0;
}
-static void read_populate_todo(struct commit_list **todo_list,
+static int read_populate_todo(struct commit_list **todo_list,
struct replay_opts *opts)
{
struct strbuf buf = STRBUF_INIT;
@@ -756,18 +756,21 @@ static void read_populate_todo(struct commit_list **todo_list,
fd = open(git_path_todo_file(), O_RDONLY);
if (fd < 0)
- die_errno(_("Could not open %s"), git_path_todo_file());
+ return error_errno(_("Could not open %s"),
+ git_path_todo_file());
if (strbuf_read(&buf, fd, 0) < 0) {
close(fd);
strbuf_release(&buf);
- die(_("Could not read %s."), git_path_todo_file());
+ return error(_("Could not read %s."), git_path_todo_file());
}
close(fd);
res = parse_insn_buffer(buf.buf, todo_list, opts);
strbuf_release(&buf);
if (res)
- die(_("Unusable instruction sheet: %s"), git_path_todo_file());
+ return error(_("Unusable instruction sheet: %s"),
+ git_path_todo_file());
+ return 0;
}
static int populate_opts_cb(const char *key, const char *value, void *data)
@@ -1019,7 +1022,8 @@ static int sequencer_continue(struct replay_opts *opts)
if (!file_exists(git_path_todo_file()))
return continue_single_pick();
read_populate_opts(&opts);
- read_populate_todo(&todo_list, opts);
+ if (read_populate_todo(&todo_list, opts))
+ return -1;
/* Verify that the conflict has been resolved */
if (file_exists(git_path_cherry_pick_head()) ||