pub fn clone_dest_cleanable(dest: &Path) -> boolExpand description
R7 clone-cleanup: whether dest is safe to remove if a clone/git_clone
about to run into it fails — either absent, or an already-empty directory.
Compute this before running the clone, and pass the result to
cleanup_failed_clone_dest on the error path — git/jj both refuse to
clone into a non-empty existing directory, so if dest already had
contents going in, a failure means that refusal, and the caller’s
pre-existing data must never be deleted. Re-checking emptiness after the
clone ran would be wrong: a failed clone can leave dest partially
populated, so a post-hoc check could wrongly call a partial clone’s leftovers
“empty” (or simply disagree with the pre-clone state).
Shared by vcs_git::clone_repo and vcs_jj::git_clone, which previously
carried a byte-identical copy of this check plus its own best-effort
remove_dir_all on the error path.