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

[PATCH 2/3] merge-recursive: fix logic ordering issue

From
Elijah Newren <newren@gmail.com>
Date
Jan 5, 2018, 20:20 UTC
Message-ID
<20180105202001.24218-3-newren@gmail.com>
In-Reply-To
<20180105202001.24218-1-newren@gmail.com>
merge_trees() did a variety of work, including:
  * Calling get_unmerged() to get unmerged entries
  * Calling record_df_conflict_files() with all unmerged entries to
    do some work to ensure we could handle D/F conflicts correctly
  * Calling get_renames() to check for renames.

An easily overlooked issue is that get_renames() can create more unmerged entries and add them to the list, which have the possibility of being involved in D/F conflicts. So the call to record_df_conflict_files() should really be moved after all the rename detection. I didn't come up with any testcases demonstrating any bugs with the old ordering, but I suspect there were some for both normal renames and for directory renames. Fix the ordering.

Reviewed-By: Stefan Beller <sbeller@google.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-recursive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/merge-recursive.c b/merge-recursive.c
index d00b27438..98c84e73d 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1982,10 +1982,10 @@ int merge_trees(struct merge_options *o,
 		get_files_dirs(o, merge);
 
 		entries = get_unmerged();
-		record_df_conflict_files(o, entries);
 		re_head  = get_renames(o, head, common, head, merge, entries);
 		re_merge = get_renames(o, merge, common, head, merge, entries);
 		clean = process_renames(o, re_head, re_merge);
+		record_df_conflict_files(o, entries);
 		if (clean < 0)
 			goto cleanup;
 		for (i = entries->nr-1; 0 <= i; i--) {
-- 
2.14.2
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 4 of 7 in “Some small fixes to merge-recursive and tests”
  1. 0/3 Some small fixes to merge-recursive and testsElijah Newren, Jan 5, 2018
  2. 1/3 Tighten and correct a few testcases for merging and cherry-pickingElijah Newren, Jan 5, 2018
  3. Johannes SchindelinJan 5, 2018
  4. 2/3 merge-recursive: fix logic ordering issueElijah Newren, Jan 5, 2018
  5. Johannes SchindelinJan 5, 2018
  6. 3/3 merge-recursive: add explanation for src_entry and dst_entryElijah Newren, Jan 5, 2018
  7. Johannes SchindelinJan 5, 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.