prune --repos: fix uninitialized access

There's a code path in prune_repo_dir() that does not initialize 'st'
buffer, which is checked by the caller, prune_repos_dir(). Instead
of leaking some prune logic out to prune_repos_dir(), move 'st' into
prune_repo_dir().
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 in remove_junk()

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).