diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2021-09-08 11:23:57 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-09-09 15:49:04 -0700 |
commit | a33806398a418289388ad992e385a314b4b10225 (patch) | |
tree | 2eb87e8c4ad8f7bbe90f88c4c10edc7245b90e50 /builtin | |
parent | diff: ignore sparse paths in diffstat (diff) | |
download | tgif-a33806398a418289388ad992e385a314b4b10225.tar.xz |
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>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/merge.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/merge.c b/builtin/merge.c index 22f23990b3..926de328fb 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1276,6 +1276,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (argc == 2 && !strcmp(argv[1], "-h")) usage_with_options(builtin_merge_usage, builtin_merge_options); + prepare_repo_settings(the_repository); + the_repository->settings.command_requires_full_index = 0; + /* * Check if we are _not_ on a detached HEAD, i.e. if there is a * current branch. |