summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Derrick Stolee <dstolee@microsoft.com>2021-07-14 13:12:25 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-07-14 13:42:21 -0700
commitfc6609d198c47bf511f3388975c7c94e0aa1af2b (patch)
tree3995ce3133182b4fe6315a10650157cbc6cd4b17 /t
parentThe second batch (diff)
downloadtgif-fc6609d198c47bf511f3388975c7c94e0aa1af2b.tar.xz
sparse-index: skip indexes with unmerged entries
The sparse-index format is designed to be compatible with merge conflicts, even those outside the sparse-checkout definition. The reason is that when converting a full index to a sparse one, a cache entry with nonzero stage will not be collapsed into a sparse directory entry. However, this behavior was not tested, and a different behavior within convert_to_sparse() fails in this scenario. Specifically, cache_tree_update() will fail when unmerged entries exist. convert_to_sparse_rec() uses the cache-tree data to recursively walk the tree structure, but also to compute the OIDs used in the sparse-directory entries. Add an index scan to convert_to_sparse() that will detect if these merge conflict entries exist and skip the conversion before trying to update the cache-tree. This is marked as NEEDSWORK because this can be removed with a suitable update to cache_tree_update() or a similar method that can construct a cache-tree with invalid nodes, but still allow creating the nodes necessary for creating sparse directory entries. It is possible that in the future we will not need to make such an update, since if we do not expand a sparse-index into a full one, this conversion does not need to happen. Thus, this can be deferred until the merge machinery is made to integrate with the sparse-index. Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1092-sparse-checkout-compatibility.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index e9a815ca7a..ba2fd94ada 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -352,6 +352,28 @@ test_expect_success 'merge with outside renames' '
done
'
+# Sparse-index fails to convert the index in the
+# final 'git cherry-pick' command.
+test_expect_success 'cherry-pick with conflicts' '
+ init_repos &&
+
+ write_script edit-conflict <<-\EOF &&
+ echo $1 >conflict
+ EOF
+
+ test_all_match git checkout -b to-cherry-pick &&
+ run_on_all ../edit-conflict ABC &&
+ test_all_match git add conflict &&
+ test_all_match git commit -m "conflict to pick" &&
+
+ test_all_match git checkout -B base HEAD~1 &&
+ run_on_all ../edit-conflict DEF &&
+ test_all_match git add conflict &&
+ test_all_match git commit -m "conflict in base" &&
+
+ test_all_match test_must_fail git cherry-pick to-cherry-pick
+'
+
test_expect_success 'clean' '
init_repos &&