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

Re: [PATCH] merge-ort: fix bug with renormalization and rename/delete conflicts

From
Derrick Stolee <stolee@gmail.com>
Date
Dec 28, 2021, 13:55 UTC
Message-ID
<78ba0d99-246b-d90c-b725-c084c8304f02@gmail.com>
In-Reply-To
<pull.1174.git.git.1640650846612.gitgitgadget@gmail.com>
On 12/27/2021 7:20 PM, Elijah Newren via GitGitGadget wrote:
Show 7 quoted lines
> From: Elijah Newren <newren@gmail.com>
> 
> Ever since commit a492d5331c ("merge-ort: ensure we consult df_conflict
> and path_conflicts", 2021-06-30), when renormalization is active AND a
> file is involved in a rename/delete conflict BUT the file is unmodified
> (either before or after renormalization), merge-ort was running into an
> assertion failure. 

This "the file is unmodified" is critical, as when I looked at the test, it seemed too simple. I asked myself, "Why does renormalization matter here?" Turns out it is just an artifact of the carefully organized cases.

Show 22 quoted lines
>  		if (opt->renormalize &&
>  		    blob_unchanged(opt, &ci->stages[0], &ci->stages[side],
>  				   path)) {
> -			ci->merged.is_null = 1;
> -			ci->merged.clean = 1;
> -			assert(!ci->df_conflict && !ci->path_conflict);
> +			if (!ci->path_conflict) {
> +				/*
> +				 * Blob unchanged after renormalization, so
> +				 * there's no modify/delete conflict after all;
> +				 * we can just remove the file.
> +				 */
> +				ci->merged.is_null = 1;
> +				ci->merged.clean = 1;
> +				 /*
> +				  * file goes away => even if there was a
> +				  * directory/file conflict there isn't one now.
> +				  */
> +				ci->df_conflict = 0;
> +			} else {
> +				/* rename/delete, so conflict remains */
> +			}

This breakdown of the cases is informative, and I like how self-contained the change is.

Show 27 quoted lines
> +test_expect_success 'rename/delete vs. renormalization' '
> +	git init subrepo &&
> +	(
> +		cd subrepo &&
> +		echo foo >oldfile &&
> +		git add oldfile &&
> +		git commit -m original &&
> +
> +		git branch rename &&
> +		git branch nuke &&
> +
> +		git checkout rename &&
> +		git mv oldfile newfile &&
> +		git commit -m renamed &&
> +
> +		git checkout nuke &&
> +		git rm oldfile &&
> +		git commit -m deleted &&
> +
> +		git checkout rename^0 &&
> +		test_must_fail git -c merge.renormalize=true merge nuke >out &&
> +
> +		grep "rename/delete" out
> +	)
> +'
> +
>  test_done
I tested this on the latest 'master' and saw the following:
  git: merge-ort.c:3846: process_entry: Assertion `!ci->df_conflict && !ci->path_conflict' failed
so it indeed hits this case.
This patch looks good to me. Thanks!
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Previous: Elijah Newren via GitGitGadgetNext: Junio C Hamano
Message 2 of 5 in “merge-ort: fix bug with renormalization and rename/delete conflicts”
  1. merge-ort: fix bug with renormalization and rename/delete conflictsElijah Newren via GitGitGadget, Dec 28, 2021
  2. Derrick StoleeDec 28, 2021
  3. Junio C HamanoDec 30, 2021
  4. Elijah NewrenDec 30, 2021
  5. merge-ort: fix bug with renormalization and rename/delete conflictsElijah Newren via GitGitGadget, Dec 30, 2021

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.