Re: [PATCH 11/18] builtin rebase: support `--autostash` option
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Aug 24, 2018, 16:06 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1808241805550.73@tvgsbejvaqbjf.bet>
- In-Reply-To
- <CACsJy8CS5aABuQrqWxdfLOTbFRhQDQ+tFO+wOCLTdeJG8mH0hw@mail.gmail.com>
Hi Duy,
On Sat, 18 Aug 2018, Duy Nguyen wrote:
Show 25 quoted lines
> On Wed, Aug 8, 2018 at 5:26 PM Pratik Karki <predatoramigo@gmail.com> wrote:
> > @@ -224,13 +219,56 @@ static int read_basic_state(struct rebase_options *opts)
> > return 0;
> > }
> >
> > +static int apply_autostash(struct rebase_options *opts)
> > +{
> > + const char *path = state_dir_path("autostash", opts);
> > + struct strbuf autostash = STRBUF_INIT;
> > + struct child_process stash_apply = CHILD_PROCESS_INIT;
> > +
> > + if (!file_exists(path))
> > + return 0;
> > +
> > + if (read_one(state_dir_path("autostash", opts), &autostash))
> > + return error(_("Could not read '%s'"), path);
> > + argv_array_pushl(&stash_apply.args,
> > + "stash", "apply", autostash.buf, NULL);
> > + stash_apply.git_cmd = 1;
> > + stash_apply.no_stderr = stash_apply.no_stdout =
> > + stash_apply.no_stdin = 1;
> > + if (!run_command(&stash_apply))
> > + printf("Applied autostash.\n");
>
> I think you need _() here.Good catch.
Will fix before sending v2, Dscho
Show 40 quoted lines
>
> > + else {
> > + struct argv_array args = ARGV_ARRAY_INIT;
> > + int res = 0;
> > +
> > + argv_array_pushl(&args,
> > + "stash", "store", "-m", "autostash", "-q",
> > + autostash.buf, NULL);
> > + if (run_command_v_opt(args.argv, RUN_GIT_CMD))
> > + res = error(_("Cannot store %s"), autostash.buf);
> > + argv_array_clear(&args);
> > + strbuf_release(&autostash);
> > + if (res)
> > + return res;
> > +
> > + fprintf(stderr,
> > + _("Applying autostash resulted in conflicts.\n"
> > + "Your changes are safe in the stash.\n"
> > + "You can run \"git stash pop\" or \"git stash drop\" "
> > + "at any time.\n"));
> > + }
> > +
> > + strbuf_release(&autostash);
> > + return 0;
> > +}
> > +
> > static int finish_rebase(struct rebase_options *opts)
> > {
> > struct strbuf dir = STRBUF_INIT;
> > const char *argv_gc_auto[] = { "gc", "--auto", NULL };
> >
> > delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
> > - apply_autostash();
> > + apply_autostash(opts);
> > close_all_packs(the_repository->objects);
> > /*
> > * We ignore errors in 'gc --auto', since the
> --
> Duy
>