Re: [PATCH v3 6/7] merge: ensure we can actually restore pre-merge state
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 21, 2022, 16:31 UTC
- Message-ID
- <xmqq35eul95b.fsf@gitster.g>
- In-Reply-To
- <887967c1f3fd6f03cf1d0bb3c19ed16819541092.1658391391.git.gitgitgadget@gmail.com>
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 13 quoted lines
> diff --git a/builtin/merge.c b/builtin/merge.c > index f807bf335bd..11bb4bab0a1 100644 > --- a/builtin/merge.c > +++ b/builtin/merge.c > @@ -1686,12 +1686,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix) > * tree in the index -- this means that the index must be in > * sync with the head commit. The strategies are responsible > * to ensure this. > + * > + * Stash away the local changes so that we can try more than one > + * and/or recover from merge strategies bailing while leaving the > + * index and working tree polluted. > */
Makes sense. We may want to special-case strategies that are known not to have the buggy "leave contaminated tree when bailing out" behaviour to avoid waste. I expect that more than 99.99% of the time people are feeding a single other commit to ort or recursive, and if these are known to be safe, a lot will be saved by not saving "just in case". But that can be left for later, after the series solidifies.
Thanks.
Show 9 quoted lines
> - if (use_strategies_nr == 1 ||
> - /*
> - * Stash away the local changes so that we can try more than one.
> - */
> - save_state(&stash))
> + if (save_state(&stash))
> oidclr(&stash);
>
> for (i = 0; !merge_was_ok && i < use_strategies_nr; i++) {