branch: git branch upstream merge has been exposed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/include/git2/branch.h b/include/git2/branch.h
index 0c0cc7f..24ea7f7 100644
--- a/include/git2/branch.h
+++ b/include/git2/branch.h
@@ -305,6 +305,19 @@ GIT_EXTERN(int) git_branch_remote_name(
GIT_EXTERN(int) git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname);
/**
+ * Retrieve the upstream merge of a local branch
+ *
+ * This will return the currently configured "branch.*.merge" for a given
+ * branch. This branch must be local.
+ *
+ * @param buf the buffer into which to write the name
+ * @param repo the repository in which to look
+ * @param refname the full name of the branch
+ * @return 0 or an error code
+ */
+ GIT_EXTERN(int) git_branch_upstream_merge(git_buf *buf, git_repository *repo, const char *refname);
+
+/**
* Determine whether a branch name is valid, meaning that (when prefixed
* with `refs/heads/`) that it is a valid reference name, and that any
* additional branch name restrictions are imposed (eg, it cannot start
diff --git a/src/branch.c b/src/branch.c
index ff790b9..55b748c 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -492,6 +492,14 @@ static int git_branch_upstream_with_format(git_buf *buf, git_repository *repo, c
return error;
}
+int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname) {
+ git_branch_upstream_with_format(buf, repo, refname, "branch.%s.remote");
+}
+
+int git_branch_upstream_merge(git_buf *buf, git_repository *repo, const char *refname) {
+ git_branch_upstream_with_format(buf, repo, refname, "branch.%s.merge");
+}
+
int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refname)
{
git_strarray remote_list = {0};