From 7e673200c84971fd93d6bbbb0be04e6bee0d922b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Sun, 23 Jan 2022 22:11:54 +0100 Subject: [PATCH] Fix error on empty cloned repository --- src/repo.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/repo.rs b/src/repo.rs index f2cc015..a680014 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -1507,8 +1507,11 @@ pub fn clone_repo( repo.rename_remote(&origin, &remote.name)?; } - let mut active_branch = repo.head_branch()?; - active_branch.set_upstream(&remote.name, &active_branch.name()?)?; + // If there is no head_branch, we most likely cloned an empty repository and + // 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(()) }