[libgit2-glib] Wrap the right type for ggit_branch_get_upstream
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Wrap the right type for ggit_branch_get_upstream
- Date: Sun, 14 Apr 2013 13:49:52 +0000 (UTC)
commit 22b336834c7da7b7a60b9f601afbc10c58364efa
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sun Apr 14 15:49:27 2013 +0200
Wrap the right type for ggit_branch_get_upstream
libgit2-glib/ggit-branch.c | 17 +++++++++++++++--
libgit2-glib/ggit-branch.h | 2 +-
2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/libgit2-glib/ggit-branch.c b/libgit2-glib/ggit-branch.c
index e16bdd1..32f84bb 100644
--- a/libgit2-glib/ggit-branch.c
+++ b/libgit2-glib/ggit-branch.c
@@ -154,12 +154,14 @@ ggit_branch_get_name (GgitBranch *branch,
*
* Returns: (transfer full) (allow-none): the reference supporting the remote tracking branch.
*/
-GgitBranch *
+GgitRef *
ggit_branch_get_upstream (GgitBranch *branch,
GError **error)
{
gint ret;
git_reference *upstream;
+ const gchar *name;
+ GgitRef *ref;
g_return_val_if_fail (GGIT_IS_BRANCH (branch), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
@@ -173,7 +175,18 @@ ggit_branch_get_upstream (GgitBranch *branch,
return NULL;
}
- return _ggit_branch_wrap (upstream);
+ name = git_reference_name (_ggit_native_get (upstream));
+
+ if (g_str_has_prefix (name, "refs/heads/"))
+ {
+ ref = GGIT_REF (_ggit_branch_wrap (upstream));
+ }
+ else
+ {
+ ref = _ggit_ref_wrap (upstream);
+ }
+
+ return ref;
}
/**
diff --git a/libgit2-glib/ggit-branch.h b/libgit2-glib/ggit-branch.h
index 033bc1f..06a8bfe 100644
--- a/libgit2-glib/ggit-branch.h
+++ b/libgit2-glib/ggit-branch.h
@@ -64,7 +64,7 @@ GgitBranch *ggit_branch_move (GgitBranch *branch,
const gchar *ggit_branch_get_name (GgitBranch *branch,
GError **error);
-GgitBranch *ggit_branch_get_upstream (GgitBranch *branch,
+GgitRef *ggit_branch_get_upstream (GgitBranch *branch,
GError **error);
gboolean ggit_branch_is_head (GgitBranch *branch,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]