@matheusbsbs / matheus-bagliano / commits / be1bb600da
Fork 0

sequencer: make apply_autostash() accept a path

In order to make apply_autostash() more generic for future extraction, make it accept a `path` argument so that the location from where to read the reference to the autostash commit can be customized. Remove the `opts` argument since it was unused before anyway. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Denton Liu committed Apr 7, 2020 at 10:27 UTC be1bb600da13523dd2d63ae93432d7f3b16ffb74
1 file changed +7 -7
sequencer.c
+7 -7
@@ -3657,13 +3657,13 @@ static enum todo_command peek_command(struct todo_list *todo_list, int offset)
3657 return -1;
3658 }
3659
3660 -static int apply_autostash(struct replay_opts *opts)
3660 +static int apply_autostash(const char *path)
3661 {
3662 struct strbuf stash_sha1 = STRBUF_INIT;
3663 struct child_process child = CHILD_PROCESS_INIT;
3664 int ret = 0;
3665
3666 - if (!read_oneliner(&stash_sha1, rebase_path_autostash(),
3666 + if (!read_oneliner(&stash_sha1, path,
3667 READ_ONELINER_SKIP_IF_EMPTY)) {
3668 strbuf_release(&stash_sha1);
3669 return 0;
@@ -3756,7 +3756,7 @@ static int checkout_onto(struct repository *r, struct replay_opts *opts,
3756 return error(_("%s: not a valid OID"), orig_head);
3757
3758 if (run_git_checkout(r, opts, oid_to_hex(onto), action)) {
3759 - apply_autostash(opts);
3759 + apply_autostash(rebase_path_autostash());
3760 sequencer_remove_state(opts);
3761 return error(_("could not detach HEAD"));
3762 }
@@ -4070,7 +4070,7 @@ cleanup_head_ref:
4070 run_command(&hook);
4071 }
4072 }
4073 - apply_autostash(opts);
4073 + apply_autostash(rebase_path_autostash());
4074
4075 if (!opts->quiet) {
4076 if (!opts->verbose)
@@ -5079,7 +5079,7 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
5079 todo_list_add_exec_commands(todo_list, commands);
5080
5081 if (count_commands(todo_list) == 0) {
5082 - apply_autostash(opts);
5082 + apply_autostash(rebase_path_autostash());
5083 sequencer_remove_state(opts);
5084
5085 return error(_("nothing to do"));
@@ -5090,12 +5090,12 @@ int complete_action(struct repository *r, struct replay_opts *opts, unsigned fla
5090 if (res == -1)
5091 return -1;
5092 else if (res == -2) {
5093 - apply_autostash(opts);
5093 + apply_autostash(rebase_path_autostash());
5094 sequencer_remove_state(opts);
5095
5096 return -1;
5097 } else if (res == -3) {
5098 - apply_autostash(opts);
5098 + apply_autostash(rebase_path_autostash());
5099 sequencer_remove_state(opts);
5100 todo_list_release(&new_todo);
5101