cherry-pick --continue: remember options

Remember --allow-empty, --allow-empty-message and --keep-redundant-commits when cherry-pick stops for a conflict resolution. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Mar 13, 2019 at 18:26 UTC 6860ce5d8e461e5997029abe73c39590d349cef9
2 files changed +20 -2
sequencer.c
+18
@@ -2308,6 +2308,15 @@ static int populate_opts_cb(const char *key, const char *value, void *data)
2308 opts->no_commit = git_config_bool_or_int(key, value, &error_flag);
2309 else if (!strcmp(key, "options.edit"))
2310 opts->edit = git_config_bool_or_int(key, value, &error_flag);
2311 + else if (!strcmp(key, "options.allow-empty"))
2312 + opts->allow_empty =
2313 + git_config_bool_or_int(key, value, &error_flag);
2314 + else if (!strcmp(key, "options.allow-empty-message"))
2315 + opts->allow_empty_message =
2316 + git_config_bool_or_int(key, value, &error_flag);
2317 + else if (!strcmp(key, "options.keep-redundant-commits"))
2318 + opts->keep_redundant_commits =
2319 + git_config_bool_or_int(key, value, &error_flag);
2320 else if (!strcmp(key, "options.signoff"))
2321 opts->signoff = git_config_bool_or_int(key, value, &error_flag);
2322 else if (!strcmp(key, "options.record-origin"))
@@ -2706,6 +2715,15 @@ static int save_opts(struct replay_opts *opts)
2715 if (opts->edit)
2716 res |= git_config_set_in_file_gently(opts_file,
2717 "options.edit", "true");
2718 + if (opts->allow_empty)
2719 + res |= git_config_set_in_file_gently(opts_file,
2720 + "options.allow-empty", "true");
2721 + if (opts->allow_empty_message)
2722 + res |= git_config_set_in_file_gently(opts_file,
2723 + "options.allow-empty-message", "true");
2724 + if (opts->keep_redundant_commits)
2725 + res |= git_config_set_in_file_gently(opts_file,
2726 + "options.keep-redundant-commits", "true");
2727 if (opts->signoff)
2728 res |= git_config_set_in_file_gently(opts_file,
2729 "options.signoff", "true");
t/t3507-cherry-pick-conflict.sh
+2 -2
@@ -410,7 +410,7 @@ test_expect_success 'cherry-pick preserves sparse-checkout' '
410 test_i18ngrep ! "Changes not staged for commit:" actual
411 '
412
413 -test_expect_failure 'cherry-pick --continue remembers --keep-redundant-commits' '
413 +test_expect_success 'cherry-pick --continue remembers --keep-redundant-commits' '
414 test_when_finished "git cherry-pick --abort || :" &&
415 pristine_detach initial &&
416 test_must_fail git cherry-pick --keep-redundant-commits picked redundant &&
@@ -419,7 +419,7 @@ test_expect_failure 'cherry-pick --continue remembers --keep-redundant-commits'
419 git cherry-pick --continue
420 '
421
422 -test_expect_failure 'cherry-pick --continue remembers --allow-empty and --allow-empty-message' '
422 +test_expect_success 'cherry-pick --continue remembers --allow-empty and --allow-empty-message' '
423 test_when_finished "git cherry-pick --abort || :" &&
424 pristine_detach initial &&
425 test_must_fail git cherry-pick --allow-empty --allow-empty-message \