Re: [RFC PATCH v1 5/6] stash: remove the second index in restore_untracked()
On Tue, May 5, 2020 at 12:56 PM Alban Gruin <alban.gruin@gmail.com> wrote:
Show 25 quoted lines
> diff --git a/builtin/stash.c b/builtin/stash.c
> index cbe37cd24b..1eafc1fe8d 100644
> --- a/builtin/stash.c
> +++ b/builtin/stash.c
> @@ -359,29 +359,16 @@ static int restore_untracked(struct object_id *u_tree)
> int res;
> struct child_process cp = CHILD_PROCESS_INIT;
>
> - /*
> - * We need to run restore files from a given index, but without
> - * affecting the current index, so we use GIT_INDEX_FILE with
> - * run_command to fork processes that will not interfere.
> - */
> - cp.git_cmd = 1;
> - argv_array_push(&cp.args, "read-tree");
> - argv_array_push(&cp.args, oid_to_hex(u_tree));
> - argv_array_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
> - stash_index_path.buf);
> - if (run_command(&cp)) {
> - remove_path(stash_index_path.buf);
> + if (reset_tree(u_tree, 0, 0))
> return -1;
> - }
>
> child_process_init(&cp);Show 11 quoted lines
> cp.git_cmd = 1;
> argv_array_pushl(&cp.args, "checkout-index", "--all", NULL);
> - argv_array_pushf(&cp.env_array, "GIT_INDEX_FILE=%s",
> - stash_index_path.buf);
>
> res = run_command(&cp);
> - remove_path(stash_index_path.buf);
> + discard_cache();
> +
> return res;
> }