From 50a0f4d76630369fde8898ad288a58bd3051a842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 26 May 2022 16:18:56 +0200 Subject: [PATCH] Fail properly when default branch cannot be detected --- src/repo.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/repo.rs b/src/repo.rs index a632cb4..d369708 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -1271,14 +1271,14 @@ impl Repo { }; let default_branch_name = match &config { - None => guess_default_branch()?, + None => guess_default_branch().ok(), Some(config) => match &config.persistent_branches { - None => guess_default_branch()?, + None => guess_default_branch().ok(), Some(persistent_branches) => { if persistent_branches.is_empty() { - guess_default_branch()? + guess_default_branch().ok() } else { - persistent_branches[0].clone() + Some(persistent_branches[0].clone()) } } }, @@ -1290,8 +1290,10 @@ impl Repo { if dirname == WORKTREE_CONFIG_FILE_NAME { continue; } - if dirname == default_branch_name { - continue; + if let Some(default_branch_name) = default_branch_name { + if dirname == default_branch_name { + continue; + } } if !&worktrees.iter().any(|worktree| worktree.name() == dirname) { unmanaged_worktrees.push(dirname);