mirror of
https://github.com/git/git.git
synced 2026-01-09 01:34:00 +00:00
t: expand tests around sparse merges and clean
With the current implementation of 'git sparse-checkout clean', we notice that a file that was in a conflicted state does not get cleaned up because of some internal details around the SKIP_WORKTREE bit. This test is documenting the current behavior before we update it in the following change. Signed-off-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
66c11bd46a
commit
592d2a93af
@@ -1183,35 +1183,47 @@ test_expect_success 'clean with sparse file states' '
|
|||||||
test_must_be_empty out
|
test_must_be_empty out
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'clean with merge conflict status' '
|
test_expect_success 'sparse-checkout operations with merge conflicts' '
|
||||||
git clone repo clean-merge &&
|
git clone repo merge &&
|
||||||
|
|
||||||
echo dirty >clean-merge/deep/deeper2/a &&
|
(
|
||||||
touch clean-merge/folder2/extra &&
|
cd merge &&
|
||||||
|
mkdir -p folder1/even/more/dirs &&
|
||||||
|
echo base >folder1/even/more/dirs/file &&
|
||||||
|
git add folder1 &&
|
||||||
|
git commit -m "base" &&
|
||||||
|
|
||||||
cat >input <<-EOF &&
|
git checkout -b right&&
|
||||||
0 $ZERO_OID folder1/a
|
echo right >folder1/even/more/dirs/file &&
|
||||||
100644 $(git -C clean-merge rev-parse HEAD:folder1/a) 1 folder1/a
|
git commit -a -m "right" &&
|
||||||
EOF
|
|
||||||
git -C clean-merge update-index --index-info <input &&
|
|
||||||
|
|
||||||
git -C clean-merge sparse-checkout set deep/deeper1 &&
|
git checkout -b left HEAD~1 &&
|
||||||
|
echo left >folder1/even/more/dirs/file &&
|
||||||
|
git commit -a -m "left" &&
|
||||||
|
|
||||||
test_must_fail git -C clean-merge sparse-checkout clean -f 2>err &&
|
git checkout -b merge &&
|
||||||
grep "failed to convert index to a sparse index" err &&
|
git sparse-checkout set deep/deeper1 &&
|
||||||
|
|
||||||
mkdir -p clean-merge/folder1/ &&
|
test_must_fail git merge -m "will-conflict" right &&
|
||||||
echo merged >clean-merge/folder1/a &&
|
|
||||||
git -C clean-merge add --sparse folder1/a &&
|
|
||||||
|
|
||||||
# deletes folder2/ but leaves staged change in folder1
|
test_must_fail git sparse-checkout clean -f 2>err &&
|
||||||
# and dirty change in deep/deeper2/
|
grep "failed to convert index to a sparse index" err &&
|
||||||
cat >expect <<-\EOF &&
|
|
||||||
Removing folder2/
|
|
||||||
EOF
|
|
||||||
|
|
||||||
git -C clean-merge sparse-checkout clean -f >out &&
|
echo merged >folder1/even/more/dirs/file &&
|
||||||
test_cmp expect out
|
git add --sparse folder1 &&
|
||||||
|
git merge --continue &&
|
||||||
|
|
||||||
|
test_path_exists folder1/even/more/dirs/file &&
|
||||||
|
|
||||||
|
# clean does not remove the file, because the
|
||||||
|
# SKIP_WORKTREE bit was not cleared by the merge command.
|
||||||
|
git sparse-checkout clean -f >out &&
|
||||||
|
test_line_count = 0 out &&
|
||||||
|
test_path_exists folder1/even/more/dirs/file &&
|
||||||
|
|
||||||
|
git sparse-checkout reapply &&
|
||||||
|
test_path_is_missing folder1
|
||||||
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
Reference in New Issue
Block a user