Skip to content

Commit a3a3c99

Browse files
vdyedscho
authored andcommitted
t1092: add test for untracked files and directories
Add a test verifying that sparse-checkout (with and without sparse index enabled) treat untracked files & directories correctly when changing sparse patterns. Specifically, it ensures that 'git sparse-checkout set' * deletes empty directories outside the sparse cone * does _not_ delete untracked files outside the sparse cone Signed-off-by: Victoria Dye <[email protected]>
1 parent 59c8897 commit a3a3c99

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,22 @@ test_expect_success 'root directory cannot be sparse' '
311311
test_cmp expect actual
312312
'
313313

314+
test_expect_success 'sparse-checkout with untracked files and dirs' '
315+
init_repos &&
316+
317+
# Empty directories outside sparse cone are deleted
318+
run_on_sparse mkdir -p deep/empty &&
319+
test_sparse_match git sparse-checkout set folder1 &&
320+
test_must_be_empty sparse-checkout-err &&
321+
run_on_sparse test_path_is_missing deep &&
322+
323+
# Untracked files outside sparse cone are not deleted
324+
run_on_sparse touch folder1/another &&
325+
test_sparse_match git sparse-checkout set folder2 &&
326+
grep "directory ${SQ}folder1/${SQ} contains untracked files" sparse-checkout-err &&
327+
run_on_sparse test_path_exists folder1/another
328+
'
329+
314330
test_expect_success 'status with options' '
315331
init_repos &&
316332
test_sparse_match ls &&

0 commit comments

Comments
 (0)