summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2016-09-09 14:37:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-09 18:24:52 (GMT)
commit0d00da7bb3780c29e3d42ee255e0a09de8c43587 (patch)
tree372f4687537d115bc5b14af0ee269365b790d37f /sequencer.c
parent0ae42a038da1f63a5b090b70502087817cc54f5d (diff)
downloadgit-0d00da7bb3780c29e3d42ee255e0a09de8c43587.zip
git-0d00da7bb3780c29e3d42ee255e0a09de8c43587.tar.gz
git-0d00da7bb3780c29e3d42ee255e0a09de8c43587.tar.bz2
sequencer: lib'ify read_populate_opts()
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_opts(), 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_opts() callable from new callers that want it not to die, without changing the external behaviour of anything existing. Note that the function git_config_from_file(), called from read_populate_opts(), can currently still die() (in git_parse_source(), because the do_config_from_file() function sets die_on_error = 1). We do not try to fix that here, as it would have larger ramifications on the config code, and we also assume that we write the opts file programmatically, hence any parse errors would be bugs. 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.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sequencer.c b/sequencer.c
index c73cdfd..1614efb 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -808,12 +808,20 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
return 0;
}
-static void read_populate_opts(struct replay_opts **opts_ptr)
+static int read_populate_opts(struct replay_opts **opts)
{
if (!file_exists(git_path_opts_file()))
- return;
- if (git_config_from_file(populate_opts_cb, git_path_opts_file(), *opts_ptr) < 0)
- die(_("Malformed options sheet: %s"), git_path_opts_file());
+ return 0;
+ /*
+ * The function git_parse_source(), called from git_config_from_file(),
+ * may die() in case of a syntactically incorrect file. We do not care
+ * about this case, though, because we wrote that file ourselves, so we
+ * are pretty certain that it is syntactically correct.
+ */
+ if (git_config_from_file(populate_opts_cb, git_path_opts_file(), *opts) < 0)
+ return error(_("Malformed options sheet: %s"),
+ git_path_opts_file());
+ return 0;
}
static int walk_revs_populate_todo(struct commit_list **todo_list,
@@ -1021,8 +1029,8 @@ static int sequencer_continue(struct replay_opts *opts)
if (!file_exists(git_path_todo_file()))
return continue_single_pick();
- read_populate_opts(&opts);
- if (read_populate_todo(&todo_list, opts))
+ if (read_populate_opts(&opts) ||
+ read_populate_todo(&todo_list, opts))
return -1;
/* Verify that the conflict has been resolved */