diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs index bf0f107755..06b75cbc4d 100644 --- a/libgit2-sys/lib.rs +++ b/libgit2-sys/lib.rs @@ -3018,6 +3018,11 @@ extern "C" { repo: *mut git_repository, refname: *const c_char, ) -> c_int; + pub fn git_branch_upstream_merge( + out: *mut git_buf, + repo: *mut git_repository, + refname: *const c_char, + ) -> c_int; // index pub fn git_index_version(index: *mut git_index) -> c_uint; diff --git a/src/repo.rs b/src/repo.rs index 074955f623..19f8c1f511 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -3136,6 +3136,19 @@ impl Repository { } } + /// Retrieve the upstream merge of a local branch, + /// configured in "branch.*.merge" + /// + /// `refname` must be in the form `refs/heads/{branch_name}` + pub fn branch_upstream_merge(&self, refname: &str) -> Result { + let refname = CString::new(refname)?; + unsafe { + let buf = Buf::new(); + try_call!(raw::git_branch_upstream_merge(buf.raw(), self.raw, refname)); + Ok(buf) + } + } + /// Apply a Diff to the given repo, making changes directly in the working directory, the index, or both. pub fn apply( &self,