From ab81047a6c5c4f98640f8a2f56e138367cfdada9 Mon Sep 17 00:00:00 2001 From: Victoria Dye Date: Tue, 1 Mar 2022 20:24:30 +0000 Subject: read-tree: make two-way merge sparse-aware Enable two-way merge with 'git read-tree' without expanding the sparse index. When in a sparse index, a two-way merge will trivially succeed as long as there are not changes to the same sparse directory in multiple trees (i.e., sparse directory-level "edit-edit" conflicts). If there are such conflicts, the merge will fail despite the possibility that individual files could merge cleanly. In order to resolve these "edit-edit" conflicts, "conflicted" sparse directories are - rather than rejected - merged by traversing their associated trees by OID. For each child of the sparse directory: 1. Files are merged as normal (see Documentation/git-read-tree.txt for details). 2. Subdirectories are treated as sparse directories and merged in 'twoway_merge'. If there are no conflicts, they are merged according to the rules in Documentation/git-read-tree.txt; otherwise, the subdirectory is recursively traversed and merged. This process allows sparse directories to be individually merged at the necessary depth *without* expanding a full index. The 't/t1092-sparse-checkout-compatibility.sh' test 'read-tree --merge with edit/edit conflicts in sparse directories' tests two-way merges with 1) changes inside sparse directories that do not conflict and 2) changes that do conflict (with the correct file(s) reported in the error message). Additionally, add two-way merge cases to 'sparse index is not expanded: read-tree' to confirm that the index is not expanded regardless of whether edit/edit conflicts are present in a sparse directory. Signed-off-by: Victoria Dye Signed-off-by: Junio C Hamano --- builtin/read-tree.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'builtin') diff --git a/builtin/read-tree.c b/builtin/read-tree.c index ec6d038242..9227f07ab1 100644 --- a/builtin/read-tree.c +++ b/builtin/read-tree.c @@ -229,11 +229,6 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix) opts.fn = opts.prefix ? bind_merge : oneway_merge; break; case 2: - /* - * TODO: update twoway_merge to handle edit/edit conflicts in - * sparse directories. - */ - ensure_full_index(&the_index); opts.fn = twoway_merge; opts.initial_checkout = is_cache_unborn(); break; -- cgit v1.2.3