| test_description='checkout must not overwrite an untracked objects' |
| TEST_PASSES_SANITIZE_LEAK=true |
| test_expect_success 'setup' ' |
| test_expect_success 'create a commit where dir a/b changed to file' ' |
| git commit -m "dir to file" |
| test_expect_success 'checkout commit with dir must not remove untracked a/b' ' |
| git commit -m "un-track the file" && |
| test_must_fail git checkout start && |
| test_expect_success 'create a commit where dir a/b changed to symlink' ' |
| rm -rf a/b && # cleanup if previous test failed |
| git checkout -f -b symlink start && |
| git commit -m "dir to symlink" |
| test_expect_success 'checkout commit with dir must not remove untracked a/b' ' |
| git commit -m "un-track the symlink" && |
| test_must_fail git checkout start |
| test_expect_success SYMLINKS 'the symlink remained' ' |
| test_when_finished "rm a/b" && |
| test_expect_success SYMLINKS 'checkout -f must not follow symlinks when removing entries' ' |
| git commit -m "add dir/f" && |
| test_path_is_file untracked/f |