Skip to content

Commit

Permalink
Improve docs for PushUpdate
Browse files Browse the repository at this point in the history
I took some of the phrasing from
https://libgit2.org/libgit2/#HEAD/type/git_push_update

Before looking at the code, I didn't realize that the functions
returning `None` means the reference name is not UTF-8, as opposed to
the reference not existing.
  • Loading branch information
ilyagr committed Apr 14, 2024
1 parent 04427a3 commit 5a5c86d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/push_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ impl PushUpdate<'_> {
unsafe { crate::opt_bytes(self, (*self.raw).src_refname).unwrap() }
}

/// Returns the source name of the reference.
/// Returns the source name of the reference, or None if it is not valid UTF-8.
pub fn src_refname(&self) -> Option<&str> {
str::from_utf8(self.src_refname_bytes()).ok()
}

/// Returns the destination name of the reference as a byte slice.
/// Returns the name of the reference to update on the server as a byte slice.
pub fn dst_refname_bytes(&self) -> &[u8] {
unsafe { crate::opt_bytes(self, (*self.raw).dst_refname).unwrap() }
}

/// Returns the destination name of the reference.
/// Returns the name of the reference to update on the server, or None if it is not valid UTF-8.
pub fn dst_refname(&self) -> Option<&str> {
str::from_utf8(self.dst_refname_bytes()).ok()
}
Expand Down

0 comments on commit 5a5c86d

Please sign in to comment.