diff --git a/src/repo.rs b/src/repo.rs index f6b92d5..206b1fe 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -1435,7 +1435,7 @@ impl<'a> Branch<'a> { } } -impl Branch<'_> { +impl<'a> Branch<'a> { pub fn commit(&self) -> Result { Ok(Commit( self.0 @@ -1445,6 +1445,15 @@ impl Branch<'_> { )) } + pub fn commit_owned(self) -> Result, String> { + Ok(Commit( + self.0 + .into_reference() + .peel_to_commit() + .map_err(convert_libgit2_error)?, + )) + } + pub fn set_upstream(&mut self, remote_name: &str, branch_name: &str) -> Result<(), String> { self.0 .set_upstream(Some(&format!("{}/{}", remote_name, branch_name)))