checkout --to: no auto-detach if the ref is already checked out

Give the user a choice in this case. If they want to detach, they can go
with '--detach --to ...', or they could switch branch of the checkout
that's holding the ref in question. Or they could just create a new
branch with '-b xxx --to yyy'
checkout --to: fix dangling pointers for deleting half-prepared dirs

junk_git_dir is set to sb_repo.buf. By the end of
prepare_linked_checkout(), sb_repo is freed and so junk_git_dir
points to nowhere. If the second checkout command fails, is_junk remains
non-zero, remove_junk() will be called and try to clean junk_git_dir,
which could be anything now (if it does not crash the program).