Fix error on empty cloned repository

This commit is contained in:
2022-01-23 22:11:54 +01:00
parent 44a716248e
commit 7e673200c8

View File

@@ -1507,8 +1507,11 @@ pub fn clone_repo(
repo.rename_remote(&origin, &remote.name)?; repo.rename_remote(&origin, &remote.name)?;
} }
let mut active_branch = repo.head_branch()?; // If there is no head_branch, we most likely cloned an empty repository and
active_branch.set_upstream(&remote.name, &active_branch.name()?)?; // there is no point in setting any upstreams.
if let Ok(mut active_branch) = repo.head_branch() {
active_branch.set_upstream(&remote.name, &active_branch.name()?)?;
};
Ok(()) Ok(())
} }