Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-09-08 14:23:58 +0300
committerJunio C Hamano <gitster@pobox.com>2021-09-10 01:49:04 +0300
commit695763679210420656f4125d9706bba25c76ae4b (patch)
tree3c482768cde72529b4a6bb0f883a7e0f5c7f53af /merge-ort.c
parenta33806398a418289388ad992e385a314b4b10225 (diff)
merge-ort: expand only for out-of-cone conflicts
Merge conflicts happen often enough to want to avoid expanding a sparse index when they happen, as long as those conflicts are within the sparse-checkout cone. If a conflict exists outside of the sparse-checkout cone, then we still need to expand before iterating over the index entries. This is critical to do in advance because of how the original_cache_nr is tracked to allow inserting and replacing cache entries. Iterate over the conflicted files and check if any paths are outside of the sparse-checkout cone. If so, then expand the full index. Add a test that demonstrates that we do not expand the index, even when we hit a conflict within the sparse-checkout cone. 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 'merge-ort.c')
-rw-r--r--merge-ort.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/merge-ort.c b/merge-ort.c
index 1531b4c94c..805f7c4139 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4060,11 +4060,18 @@ static int record_conflicted_index_entries(struct merge_options *opt)
/*
* We are in a conflicted state. These conflicts might be inside
- * sparse-directory entries, so expand the index preemptively.
- * Also, we set original_cache_nr below, but that might change if
+ * sparse-directory entries, so check if any entries are outside
+ * of the sparse-checkout cone preemptively.
+ *
+ * We set original_cache_nr below, but that might change if
* index_name_pos() calls ask for paths within sparse directories.
*/
- ensure_full_index(index);
+ strmap_for_each_entry(&opt->priv->conflicted, &iter, e) {
+ if (!path_in_sparse_checkout(e->key, index)) {
+ ensure_full_index(index);
+ break;
+ }
+ }
/* If any entries have skip_worktree set, we'll have to check 'em out */
state.force = 1;