3 test_description
='checkout must not overwrite an untracked objects'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'setup' '
17 test_expect_success
'create a commit where dir a/b changed to file' '
19 git checkout -b file &&
23 git commit -m "dir to file"
26 test_expect_success
'checkout commit with dir must not remove untracked a/b' '
28 git rm --cached a/b &&
29 git commit -m "un-track the file" &&
30 test_must_fail git checkout start &&
34 test_expect_success
'create a commit where dir a/b changed to symlink' '
36 rm -rf a/b && # cleanup if previous test failed
37 git checkout -f -b symlink start &&
40 test_ln_s_add foo a/b &&
41 git commit -m "dir to symlink"
44 test_expect_success
'checkout commit with dir must not remove untracked a/b' '
46 git rm --cached a/b &&
47 git commit -m "un-track the symlink" &&
48 test_must_fail git checkout start
51 test_expect_success SYMLINKS
'the symlink remained' '
53 test_when_finished "rm a/b" &&
57 test_expect_success SYMLINKS
'checkout -f must not follow symlinks when removing entries' '
58 git checkout -f start &&
62 git commit -m "add dir/f" &&
64 ln -s untracked dir &&
65 git checkout -f HEAD~ &&
66 test_path_is_file untracked/f