summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-05-21 09:32:35 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-05-21 12:12:32 +0200
commitd22db24fb75134f30c3a72af0bc47fc7f0a07f33 (patch)
tree5f9b1cdeb1432a0da1c88fad05abd4cfb2cc9011 /include
parent04865aa05e9d16ad56920103678ee4c34578da78 (diff)
downloadlibgit2-d22db24fb75134f30c3a72af0bc47fc7f0a07f33.tar.gz
remote: add api to guess the remote's default branch
If the remote supports the symref protocol extension, then we return that, otherwise we guess with git's rules.
Diffstat (limited to 'include')
-rw-r--r--include/git2/remote.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 07cd2e7c6..28771ac42 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -623,6 +623,24 @@ GIT_EXTERN(int) git_remote_is_valid_name(const char *remote_name);
*/
GIT_EXTERN(int) git_remote_delete(git_remote *remote);
+/**
+ * Retrieve the name of the remote's default branch
+ *
+ * The default branch of a repository is the branch which HEAD points
+ * to. If the remote does not support reporting this information
+ * directly, it performs the guess as git does; that is, if there are
+ * multiple branches which point to the same commit, the first one is
+ * chosen. If the master branch is a candidate, it wins.
+ *
+ * This function must only be called after connecting.
+ *
+ * @param out the buffern in which to store the reference name
+ * @param remote the remote
+ * @return 0, GIT_ENOTFOUND if the remote does not have any references
+ * or none of them point to HEAD's commit, or an error message.
+ */
+GIT_EXTERN(int) git_remote_default_branch(git_buf *out, git_remote *remote);
+
/** @} */
GIT_END_DECL
#endif