712
return 0;
713
}
714
715
-static int apply_autostash(struct rebase_options *opts)
716
-{
717
- const char *path = state_dir_path("autostash", opts);
718
- struct strbuf autostash = STRBUF_INIT;
719
- struct child_process stash_apply = CHILD_PROCESS_INIT;
720
-
721
- if (!file_exists(path))
722
- return 0;
723
-
724
- if (!read_oneliner(&autostash, path, READ_ONELINER_WARN_MISSING))
725
- return error(_("Could not read '%s'"), path);
726
- /* Ensure that the hash is not mistaken for a number */
727
- strbuf_addstr(&autostash, "^0");
728
- argv_array_pushl(&stash_apply.args,
729
- "stash", "apply", autostash.buf, NULL);
730
- stash_apply.git_cmd = 1;
731
- stash_apply.no_stderr = stash_apply.no_stdout =
732
- stash_apply.no_stdin = 1;
733
- if (!run_command(&stash_apply))
734
- printf(_("Applied autostash.\n"));
735
- else {
736
- struct argv_array args = ARGV_ARRAY_INIT;
737
- int res = 0;
738
-
739
- argv_array_pushl(&args,
740
- "stash", "store", "-m", "autostash", "-q",
741
- autostash.buf, NULL);
742
- if (run_command_v_opt(args.argv, RUN_GIT_CMD))
743
- res = error(_("Cannot store %s"), autostash.buf);
744
- argv_array_clear(&args);
745
- strbuf_release(&autostash);
746
- if (res)
747
- return res;
748
-
749
- fprintf(stderr,
750
- _("Applying autostash resulted in conflicts.\n"
751
- "Your changes are safe in the stash.\n"
752
- "You can run \"git stash pop\" or \"git stash drop\" "
753
- "at any time.\n"));
754
- }
755
-
756
- strbuf_release(&autostash);
757
- return 0;
758
-}
759
-
715
static int finish_rebase(struct rebase_options *opts)
716
{
717
struct strbuf dir = STRBUF_INIT;
719
int ret = 0;
720
721
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
767
- apply_autostash(opts);
722
+ apply_autostash(state_dir_path("autostash", opts));
723
close_object_store(the_repository->objects);
724
/*
725
* We ignore errors in 'gc --auto', since the
1164
} else if (status == 2) {
1165
struct strbuf dir = STRBUF_INIT;
1166
1212
- apply_autostash(opts);
1167
+ apply_autostash(state_dir_path("autostash", opts));
1168
strbuf_addstr(&dir, opts->state_dir);
1169
remove_dir_recursively(&dir, 0);
1170
strbuf_release(&dir);