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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Feb 22, 2016 at 12:23 UTC 6c24dfb67e570407a87fb4ea4bf1c64ad89d5d88
1 file changed +11 -11
sequencer.c
+11 -11
@@ -933,31 +933,31 @@ static void save_opts(struct replay_opts *opts)
933 const char *opts_file = git_path_opts_file();
934
935 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");
937 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");
939 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");
941 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");
943 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");
945 if (opts->mainline) {
946 struct strbuf buf = STRBUF_INIT;
947 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);
949 strbuf_release(&buf);
950 }
951 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);
953 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);
955 if (opts->xopts) {
956 int i;
957 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);
961 }
962 }
963