Re: [PATCH v2 4/6] merge: make restore_state() restore staged state too
- From
ZheNing Hu <adlternative@gmail.com>
- Date
- Jul 17, 2022, 16:37 UTC
- Message-ID
- <CAOLTT8RhMZDYM0tuTR64VQRPaj8ghkU=jJdOnodV1txsXXpUQA@mail.gmail.com>
- In-Reply-To
- <4a8b7c9e06df36444b94b929b2558f40e3f72e81.1655621424.git.gitgitgadget@gmail.com>
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com> 于2022年6月19日周日 14:50写道:
Show 38 quoted lines
>
> From: Elijah Newren <newren@gmail.com>
>
> merge can be invoked with uncommitted changes, including staged changes.
> merge is responsible for restoring this state if some of the merge
> strategies make changes. However, it was not restoring staged changes
> due to the lack of the "--index" option to "git stash apply". Add the
> option to fix this shortcoming.
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
> builtin/merge.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/merge.c b/builtin/merge.c
> index 8ce4336dd3f..2dc56fab70b 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -383,14 +383,14 @@ static void reset_hard(const struct object_id *oid, int verbose)
> static void restore_state(const struct object_id *head,
> const struct object_id *stash)
> {
> - const char *args[] = { "stash", "apply", NULL, NULL };
> + const char *args[] = { "stash", "apply", "--index", NULL, NULL };
>
> if (is_null_oid(stash))
> return;
>
> reset_hard(head, 1);
>
> - args[2] = oid_to_hex(stash);
> + args[3] = oid_to_hex(stash);
>
> /*
> * It is OK to ignore error here, for example when there was
> --
> gitgitgadget
>Now git merge (all strategies) can learn to restore origin index state. LGTM.
ZheNing Hu