diff --git a/src/vcs.rs b/src/vcs.rs index f019154..280071d 100644 --- a/src/vcs.rs +++ b/src/vcs.rs @@ -326,9 +326,12 @@ impl Vcs { } } - let current_ref = project.repo.current_ref()?; // stash changes before moving project off to a new ref - let stashed_changes = project.repo.stash_changes(¤t_ref)?; + let stashed_changes = if let Some(current_ref) = project.current_ref()? { + project.repo.stash_changes(¤t_ref)? + } else { + false + }; // try to switch to new ref using provided setter let new_ref = match setter(project) { @@ -371,8 +374,9 @@ impl Vcs { let mut table = Table::new(); for project in &self.projects { - let head_ref_name = project.repo.current_ref()?; - table.insert(project.name().into(), Value::String(head_ref_name)); + if let Some(head_ref_name) = project.current_ref()? { + table.insert(project.name().into(), Value::String(head_ref_name)); + } } Ok(Value::Table(table))