Skip to content

Commit 7d9599b

Browse files
committed
branch: git branch upstream merge has been exposed.
1 parent a2d953e commit 7d9599b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

include/git2/branch.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,19 @@ GIT_EXTERN(int) git_branch_remote_name(
304304
*/
305305
GIT_EXTERN(int) git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname);
306306

307+
/**
308+
* Retrieve the upstream merge of a local branch
309+
*
310+
* This will return the currently configured "branch.*.merge" for a given
311+
* branch. This branch must be local.
312+
*
313+
* @param buf the buffer into which to write the name
314+
* @param repo the repository in which to look
315+
* @param refname the full name of the branch
316+
* @return 0 or an error code
317+
*/
318+
GIT_EXTERN(int) git_branch_upstream_merge(git_buf *buf, git_repository *repo, const char *refname);
319+
307320
/**
308321
* Determine whether a branch name is valid, meaning that (when prefixed
309322
* with `refs/heads/`) that it is a valid reference name, and that any

src/branch.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,14 @@ static int git_branch_upstream_with_format(git_buf *buf, git_repository *repo, c
492492
return error;
493493
}
494494

495+
int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname) {
496+
git_branch_upstream_with_format(buf, repo, refname, "branch.%s.remote");
497+
}
498+
499+
int git_branch_upstream_merge(git_buf *buf, git_repository *repo, const char *refname) {
500+
git_branch_upstream_with_format(buf, repo, refname, "branch.%s.merge");
501+
}
502+
495503
int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refname)
496504
{
497505
git_strarray remote_list = {0};

0 commit comments

Comments
 (0)