Re: [PATCH v2 6/6] merge: do not exit restore_state() prematurely
- From
ZheNing Hu <adlternative@gmail.com>
- Date
- Jul 17, 2022, 16:44 UTC
- Message-ID
- <CAOLTT8QtqVotu8Y0JYDFdxz2p2MvRitGgrfLJ_yCnT0XZoB40Q@mail.gmail.com>
- In-Reply-To
- <0783b48c121fe74051c13e7d9118d1a5b7cb9aa9.1655621424.git.gitgitgadget@gmail.com>
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com> 于2022年6月19日周日 14:50写道:
Show 13 quoted lines
>
> From: Elijah Newren <newren@gmail.com>
>
> @@ -398,7 +398,9 @@ static void restore_state(const struct object_id *head,
> */
> run_command_v_opt(args, RUN_GIT_CMD);
>
> - refresh_cache(REFRESH_QUIET);
> +refresh_cache:
> + if (discard_cache() < 0 || read_cache() < 0)
> + die(_("could not read index"));
> }
>We don't need to check discard_cache() return value, it's equal to zero constantly.
Show 31 quoted lines
> /* This is called when no merge was necessary. */ > diff --git a/t/t7607-merge-state.sh b/t/t7607-merge-state.sh > new file mode 100755 > index 00000000000..655478cd0b3 > --- /dev/null > +++ b/t/t7607-merge-state.sh > @@ -0,0 +1,25 @@ > +#!/bin/sh > + > +test_description="Test that merge state is as expected after failed merge" > + > +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main > +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME > +. ./test-lib.sh > + > +test_expect_success 'set up custom strategy' ' > + test_commit --no-tag "Initial" base base && > +git show-ref && > + > + for b in branch1 branch2 branch3 > + do > + git checkout -b $b main && > + test_commit --no-tag "Change on $b" base $b > + done && > + > + git checkout branch1 && > + test_must_fail git merge branch2 branch3 && > + git diff --exit-code --name-status && > + test_path_is_missing .git/MERGE_HEAD > +' > +
Little typo: less a small tab before "git show ref"?
> +test_done > -- > gitgitgadget