stash: apply stash using 'merge_ort_nonrecursive()'
commit874cf2a6044462ddba7162730557354a107c3a6d
authorVictoria Dye <vdye@github.com>
Tue, 10 May 2022 23:32:31 +0000 (10 23:32 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 May 2022 23:45:12 +0000 (10 16:45 -0700)
tree1cb2b91c060bc837cc9e9ffc6c49f627b539a931
parent491df5f679f0381f529b967df25476ab944406ab
stash: apply stash using 'merge_ort_nonrecursive()'

Update 'stash' to use 'merge_ort_nonrecursive()' to apply a stash to the
current working tree. When 'git stash apply' was converted from its shell
script implementation to a builtin in 8a0fc8d19d (stash: convert apply to
builtin, 2019-02-25), 'merge_recursive_generic()' was used to merge a stash
into the working tree as part of 'git stash (apply|pop)'. However, with the
single merge base used in 'do_apply_stash()', the commit wrapping done by
'merge_recursive_generic()' is not only unnecessary, but misleading (the
*real* merge base is labeled "constructed merge base"). Therefore, a
non-recursive merge of the working tree, stashed tree, and stash base tree
is more appropriate.

There are two options for a non-recursive merge-then-update-worktree
function: 'merge_trees()' and 'merge_ort_nonrecursive()'. Use
'merge_ort_nonrecursive()' to align with the default merge strategy used by
'git merge' (6a5fb96672 (Change default merge backend from recursive to ort,
2021-08-04)) and, because merge-ort does not operate in-place on the index,
avoid unnecessary index expansion. Update tests in 't1092' verifying index
expansion for 'git stash' accordingly.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/stash.c
t/t1092-sparse-checkout-compatibility.sh