Skip to content

Commit 6c24dfb

Browse files
pks-tgitster
authored andcommitted
sequencer: die on config error when saving replay opts
When we start picking a range of revisions we save the replay options that are required to restore state when interrupting and later continuing picking the revisions. However, we do not check the return values of the `git_config_set` functions, which may lead us to store incomplete information. As this may lead us to fail when trying to continue the sequence the error can be fatal. Fix this by dying immediately when we are unable to write back any replay option. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 695009b commit 6c24dfb

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

sequencer.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -933,31 +933,31 @@ static void save_opts(struct replay_opts *opts)
933933
const char *opts_file = git_path_opts_file();
934934

935935
if (opts->no_commit)
936-
git_config_set_in_file(opts_file, "options.no-commit", "true");
936+
git_config_set_in_file_or_die(opts_file, "options.no-commit", "true");
937937
if (opts->edit)
938-
git_config_set_in_file(opts_file, "options.edit", "true");
938+
git_config_set_in_file_or_die(opts_file, "options.edit", "true");
939939
if (opts->signoff)
940-
git_config_set_in_file(opts_file, "options.signoff", "true");
940+
git_config_set_in_file_or_die(opts_file, "options.signoff", "true");
941941
if (opts->record_origin)
942-
git_config_set_in_file(opts_file, "options.record-origin", "true");
942+
git_config_set_in_file_or_die(opts_file, "options.record-origin", "true");
943943
if (opts->allow_ff)
944-
git_config_set_in_file(opts_file, "options.allow-ff", "true");
944+
git_config_set_in_file_or_die(opts_file, "options.allow-ff", "true");
945945
if (opts->mainline) {
946946
struct strbuf buf = STRBUF_INIT;
947947
strbuf_addf(&buf, "%d", opts->mainline);
948-
git_config_set_in_file(opts_file, "options.mainline", buf.buf);
948+
git_config_set_in_file_or_die(opts_file, "options.mainline", buf.buf);
949949
strbuf_release(&buf);
950950
}
951951
if (opts->strategy)
952-
git_config_set_in_file(opts_file, "options.strategy", opts->strategy);
952+
git_config_set_in_file_or_die(opts_file, "options.strategy", opts->strategy);
953953
if (opts->gpg_sign)
954-
git_config_set_in_file(opts_file, "options.gpg-sign", opts->gpg_sign);
954+
git_config_set_in_file_or_die(opts_file, "options.gpg-sign", opts->gpg_sign);
955955
if (opts->xopts) {
956956
int i;
957957
for (i = 0; i < opts->xopts_nr; i++)
958-
git_config_set_multivar_in_file(opts_file,
959-
"options.strategy-option",
960-
opts->xopts[i], "^$", 0);
958+
git_config_set_multivar_in_file_or_die(opts_file,
959+
"options.strategy-option",
960+
opts->xopts[i], "^$", 0);
961961
}
962962
}
963963

0 commit comments

Comments
 (0)