Skip to content

Commit d1ae3b6

Browse files
authored
Merge pull request rust-lang#1131 from vlad-anger/expose/git_branch_upstream_merge
expose libgit2 `git_branch_upstream_merge`
2 parents 64017cd + 84e39e4 commit d1ae3b6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

libgit2-sys/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -3018,6 +3018,11 @@ extern "C" {
30183018
repo: *mut git_repository,
30193019
refname: *const c_char,
30203020
) -> c_int;
3021+
pub fn git_branch_upstream_merge(
3022+
out: *mut git_buf,
3023+
repo: *mut git_repository,
3024+
refname: *const c_char,
3025+
) -> c_int;
30213026

30223027
// index
30233028
pub fn git_index_version(index: *mut git_index) -> c_uint;

src/repo.rs

+13
Original file line numberDiff line numberDiff line change
@@ -3136,6 +3136,19 @@ impl Repository {
31363136
}
31373137
}
31383138

3139+
/// Retrieve the upstream merge of a local branch,
3140+
/// configured in "branch.*.merge"
3141+
///
3142+
/// `refname` must be in the form `refs/heads/{branch_name}`
3143+
pub fn branch_upstream_merge(&self, refname: &str) -> Result<Buf, Error> {
3144+
let refname = CString::new(refname)?;
3145+
unsafe {
3146+
let buf = Buf::new();
3147+
try_call!(raw::git_branch_upstream_merge(buf.raw(), self.raw, refname));
3148+
Ok(buf)
3149+
}
3150+
}
3151+
31393152
/// Apply a Diff to the given repo, making changes directly in the working directory, the index, or both.
31403153
pub fn apply(
31413154
&self,

0 commit comments

Comments
 (0)