Skip to content

Commit

Permalink
fix: don't crash on detached heads (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jan 26, 2024
1 parent 7892013 commit 57f6e2b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/git/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ pub fn collect(repo: &gix::Repository) -> anyhow::Result<Option<commit::History>
let mut head = handle.head()?;
let id = head
.try_peel_to_id_in_place()?
.context("Refusing to operate on a detached head.")?;
.context("Refusing to operate on a unborn head.")?;
let reference = match head.kind {
head::Kind::Detached { .. } => unreachable!("handled above"),
head::Kind::Unborn { .. } => return Ok(None),
head::Kind::Detached { .. } => return Ok(None),
head::Kind::Unborn { .. } => unreachable!("handled above"),
head::Kind::Symbolic(r) => r.attach(&handle),
};

Expand Down

0 comments on commit 57f6e2b

Please sign in to comment.