git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/5] rebase -r: demonstrate bug with conflicting merges

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 13, 2018, 02:29 UTC
Message-ID
<xmqqh8glyajx.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<efdd3736a96f90a4ab52acaf2e5efbe3435bcb89.1542065154.git.gitgitgadget@gmail.com>

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:

Show 13 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> When calling `merge` on a branch that has already been merged, that
> `merge` is skipped quietly, but currently a MERGE_HEAD file is being
> left behind and will then be grabbed by the next `pick` (that did
> not want to create a *merge* commit).
>
> Demonstrate this.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  t/t3430-rebase-merges.sh | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)

For a trivially small change/fix like this, it is OK and even preferrable to make 1+2 a single step, as applying t/ part only to try to see the breakage (or "am"ing everything and then "diff | apply -R" the part outside t/ for the same purpose) is easy enough.

Because the patch 2 with your method ends up showing only the test set-up part in the context by changing _failure to _success, without showing what end-user visible breakage the step fixed, which usually comes near the end of the added test piece. A single patch that gives tests that ought to succeed would not force the readers to switch between patches 1 and 2 while reading the fix.

Of course, the above would not apply for a more involved case where the actual fix to the code needs to span multiple patches.

Thanks.
Show 17 quoted lines
> diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh
> index aa7bfc88ec..1f08a33687 100755
> --- a/t/t3430-rebase-merges.sh
> +++ b/t/t3430-rebase-merges.sh
> @@ -396,4 +396,20 @@ test_expect_success 'with --autosquash and --exec' '
>  	grep "G: +G" actual
>  '
>  
> +test_expect_failure '--continue after resolving conflicts after a merge' '
> +	git checkout -b already-has-g E &&
> +	git cherry-pick E..G &&
> +	test_commit H2 &&
> +
> +	git checkout -b conflicts-in-merge H &&
> +	test_commit H2 H2.t conflicts H2-conflict &&
> +	test_must_fail git rebase -r already-has-g &&
> +	grep conflicts H2.t &&

Is this making sure that the above test_must_fail succeeded because of a conflict and not due to any other failure? I would have used "ls-files -u H2.t" to see if the index is unmerged, which probably is a more direct way to test what this is trying to test, but if we are in the conflicted state, the one side of << == >> has this string (the other has "H2" in it, presumably?), so in practice this should be good enough.

> +	echo resolved >H2.t &&
> +	git add -u &&
and we resolve to continue.
> +	git rebase --continue &&
> +	test_must_fail git rev-parse --verify HEAD^2 &&

Even if we made an octopus by mistake, the above will catch it, which is good.

> +	test_path_is_missing .git/MERGE_HEAD
> +'
> +
>  test_done

And from the proposed log message, I am reading that the last two things (i.e. resulting tip is a child with a single parent and there is no leftover MERGE_HEAD file) fail without the fix.

This is enough material to convince me or anybody that the bug is worth fixing. Thanks for being careful noticing a glitch during your real (and otherwise unrelated to the bug) work and following through.

Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin
Message 3 of 14 in “Assorted fixes revolving around rebase and merges”
  1. 0/5 Assorted fixes revolving around rebase and mergesJohannes Schindelin via GitGitGadget, Nov 12, 2018
  2. 1/5 rebase -r: demonstrate bug with conflicting mergesJohannes Schindelin via GitGitGadget, Nov 12, 2018
  3. Junio C HamanoNov 13, 2018
  4. Johannes SchindelinNov 13, 2018
  5. Junio C HamanoNov 13, 2018
  6. Johannes SchindelinNov 13, 2018
  7. Junio C HamanoNov 13, 2018
  8. 2/5 rebase -r: do not write MERGE_HEAD unless neededJohannes Schindelin via GitGitGadget, Nov 12, 2018
  9. 3/5 rebase -i: include MERGE_HEAD into files to clean upJohannes Schindelin via GitGitGadget, Nov 12, 2018
  10. Junio C HamanoNov 13, 2018
  11. 4/5 built-in rebase --skip/--abort: clean up stale .git/<name> filesJohannes Schindelin via GitGitGadget, Nov 12, 2018
  12. Junio C HamanoNov 13, 2018
  13. Johannes SchindelinNov 13, 2018
  14. 5/5 status: rebase and merge can be in progress at the same timeJohannes Schindelin via GitGitGadget, Nov 12, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.