merge: make sparse-aware with ORT
Allow 'git merge' to operate without expanding a sparse index, at least not immediately. The index still will be expanded in a few cases: 1. If the merge strategy is 'recursive', then we enable command_requires_full_index at the start of the merge_recursive() method. We expect sparse-index users to also have the 'ort' strategy enabled. 2. With the 'ort' strategy, if the merge results in a conflicted file, then we expand the index before updating the working tree. The loop that iterates over the worktree replaces index entries and tracks 'origintal_cache_nr' which can become completely wrong if the index expands in the middle of the operation. This safety valve is important before that loop starts. A later change will focus this to only expand if we indeed have a conflict outside of the sparse-checkout cone. 3. Other merge strategies are executed as a 'git merge-X' subcommand, and those strategies are currently protected with the 'command_requires_full_index' guard. Some test updates are required, including a mistaken 'git checkout -b' that did not specify the base branch, causing merges to be fast-forward merges. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
ad90da7351
commit
a33806398a
@ -3750,6 +3750,9 @@ int merge_recursive(struct merge_options *opt,
|
||||
assert(opt->ancestor == NULL ||
|
||||
!strcmp(opt->ancestor, "constructed merge base"));
|
||||
|
||||
prepare_repo_settings(opt->repo);
|
||||
opt->repo->settings.command_requires_full_index = 1;
|
||||
|
||||
if (merge_start(opt, repo_get_commit_tree(opt->repo, h1)))
|
||||
return -1;
|
||||
clean = merge_recursive_internal(opt, h1, h2, merge_bases, result);
|
||||
|
||||
Reference in New Issue
Block a user