Elijah Newren <newren@xxxxxxxxx> writes: > ... > So, load the index in builtin/merge-recursive.c, reload the in-memory > index in builtin/stash.c, and modify the t3030 testcase to correctly > setup the index and make sure that the test fails in the expected way > (meaning it reports a rename/rename conflict). The last paragraph is what describes what this step does. What is left unsaid is how that small step relates to the change in the larger picture (including the title). We do want to have a code that ensures the index has no higher-stage entries and match HEAD at the beginning of merge_recursive backend (as your lengthy preamble leading to the paragraph explains), but adding the code to populate in-core index to two codepaths does not make them check the condition automatically---it is only half the story, no? > Signed-off-by: Elijah Newren <newren@xxxxxxxxx> > --- > builtin/merge-recursive.c | 4 ++++ > builtin/stash.c | 2 ++ > t/t3030-merge-recursive.sh | 9 ++++++++- > 3 files changed, 14 insertions(+), 1 deletion(-) > > diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c > index 5b910e351e..a4bfd8fc51 100644 > --- a/builtin/merge-recursive.c > +++ b/builtin/merge-recursive.c > @@ -1,3 +1,4 @@ > +#include "cache.h" > #include "builtin.h" > #include "commit.h" > #include "tag.h" > @@ -63,6 +64,9 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix) > if (argc - i != 3) /* "--" "<head>" "<remote>" */ > die(_("not handling anything other than two heads merge.")); > > + if (repo_read_index_unmerged(the_repository)) > + die_resolve_conflict("merge"); > + > o.branch1 = argv[++i]; > o.branch2 = argv[++i]; > > diff --git a/builtin/stash.c b/builtin/stash.c > index b5a301f24d..4aa47785f9 100644 > --- a/builtin/stash.c > +++ b/builtin/stash.c > @@ -427,6 +427,8 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, > return error(_("could not save index tree")); > > reset_head(); > + discard_cache(); > + read_cache(); > } > } > > diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh > index ff641b348a..a37bcc58a0 100755 > --- a/t/t3030-merge-recursive.sh > +++ b/t/t3030-merge-recursive.sh > @@ -667,15 +667,22 @@ test_expect_success 'merging with triple rename across D/F conflict' ' > test_expect_success 'merge-recursive remembers the names of all base trees' ' > git reset --hard HEAD && > > + # make the index match $c1 so that merge-recursive below does not > + # fail early > + git diff --binary HEAD $c1 -- | git apply --cached && > + > # more trees than static slots used by oid_to_hex() > for commit in $c0 $c2 $c4 $c5 $c6 $c7 > do > git rev-parse "$commit^{tree}" > done >trees && > > - # ignore the return code -- it only fails because the input is weird > + # ignore the return code; it only fails because the input is weird... > test_must_fail git -c merge.verbosity=5 merge-recursive $(cat trees) -- $c1 $c3 >out && > > + # ...but make sure it fails in the expected way > + test_i18ngrep CONFLICT.*rename/rename out && > + > # merge-recursive prints in reverse order, but we do not care > sort <trees >expect && > sed -n "s/^virtual //p" out | sort >actual &&