Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,16 @@ extern "C" {
) -> c_int;
pub fn git_branch_upstream(out: *mut *mut git_reference, branch: *const git_reference)
-> c_int;
pub fn git_branch_upstream_name(
out: *mut git_buf,
repo: *mut git_repository,
refname: *const c_char,
) -> c_int;
pub fn git_branch_upstream_remote(
out: *mut git_buf,
repo: *mut git_repository,
refname: *const c_char,
) -> c_int;

// index
pub fn git_index_add(index: *mut git_index, entry: *const git_index_entry) -> c_int;
Expand Down
25 changes: 25 additions & 0 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,31 @@ impl Repository {
Ok(())
}
}

/// 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<Buf, Error> {
let refname = CString::new(refname)?;
unsafe {
let buf = Buf::new();
try_call!(raw::git_branch_upstream_name(buf.raw(), self.raw, refname));
Ok(buf)
}
}

/// Retrieve the name of the upstream remote of a local branch.
pub fn branch_upstream_remote(&self, refname: &str) -> Result<Buf, Error> {
let refname = CString::new(refname)?;
unsafe {
let buf = Buf::new();
try_call!(raw::git_branch_upstream_remote(
buf.raw(),
self.raw,
refname
));
Ok(buf)
}
}
}

impl Binding for Repository {
Expand Down