Re: [PATCH 07/15] sequencer: lib'ify read_populate_opts()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 26, 2016, 17:40 UTC
- Message-ID
- <xmqq1t1big38.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <85a8ec8273994c599402c380abd383ad2f539777.1471968378.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
Show 12 quoted lines
> -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;
> + 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;This may not be sufficient to avoid die(), unless we know that the file we are reading is syntactically sound. git_config_from_file() will die in config.c::git_parse_source() when the config_source sets die_on_error, and it is set in config.c::do_config_from_file().
The source we are reading from is created when the sequencer machinery starts and is only written by save_opts() which is called by the sequencer machinery using git_config_set*() calls, so I think it is OK to assume that we won't hit errors that would cause git_config_from_file() to die, at least for now.