repo: fix crash on upgrade of repo backed by external Git repo

If the repo is backed by Git repo that's not inside `.jj/`, then
there's no `.jj/git/` directory to move into `.jj/store/`.
This commit is contained in:
Martin von Zweigbergk 2021-10-13 23:56:46 -07:00
parent 97b48635f6
commit 6722a79e27

View File

@ -399,7 +399,9 @@ impl RepoLoader {
let git_backend_path_str = contents[5..].to_string();
fs::remove_file(&store_path).unwrap();
fs::create_dir(&store_path).unwrap();
fs::rename(repo_path.join("git"), store_path.join("git")).unwrap();
if repo_path.join("git").is_dir() {
fs::rename(repo_path.join("git"), store_path.join("git")).unwrap();
}
fs::write(store_path.join("git_target"), &git_backend_path_str).unwrap();
println!("Done. .jj/git is now .jj/store/git");
}