From 1512bf1a7f5291629262f70da4360539e7954770 Mon Sep 17 00:00:00 2001 From: Kinch Date: Thu, 11 Jun 2020 10:17:43 +0200 Subject: [PATCH] Add bindings for `git_branch_remote_name` --- libgit2-sys/lib.rs | 5 +++++ src/repo.rs | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs index f3c189cab5..eca52a0423 100644 --- a/libgit2-sys/lib.rs +++ b/libgit2-sys/lib.rs @@ -2577,6 +2577,11 @@ extern "C" { force: c_int, ) -> c_int; pub fn git_branch_name(out: *mut *const c_char, branch: *const git_reference) -> c_int; + pub fn git_branch_remote_name( + out: *mut git_buf, + repo: *mut git_repository, + refname: *const c_char, + ) -> c_int; pub fn git_branch_next( out: *mut *mut git_reference, out_type: *mut git_branch_t, diff --git a/src/repo.rs b/src/repo.rs index 437022ed2c..04faa92b1e 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -2668,6 +2668,16 @@ impl Repository { } } + /// Find the remote name of a remote-tracking branch + pub fn branch_remote_name(&self, refname: &str) -> Result { + let refname = CString::new(refname)?; + unsafe { + let buf = Buf::new(); + try_call!(raw::git_branch_remote_name(buf.raw(), self.raw, refname)); + Ok(buf) + } + } + /// Retrieves the name of the reference supporting the remote tracking branch, /// given the name of a local branch reference. pub fn branch_upstream_name(&self, refname: &str) -> Result {