[libgit2-glib] Update for api changes



commit 9cdb57ab39616d867945596e74af04b454ff9998
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Fri Mar 8 08:48:37 2013 +0100

    Update for api changes

 libgit2-glib/ggit-branch.c |   17 +++++--
 libgit2-glib/ggit-branch.h |    2 +-
 libgit2-glib/ggit-ref.c    |  105 +++++++++++++++++++++++++++++---------------
 libgit2-glib/ggit-ref.h    |    6 +-
 libgit2-glib/ggit-types.c  |    2 -
 libgit2-glib/ggit-types.h  |    6 +--
 6 files changed, 86 insertions(+), 52 deletions(-)
---
diff --git a/libgit2-glib/ggit-branch.c b/libgit2-glib/ggit-branch.c
index 68a2cf8..57f9edc 100644
--- a/libgit2-glib/ggit-branch.c
+++ b/libgit2-glib/ggit-branch.c
@@ -80,30 +80,37 @@ ggit_branch_delete (GgitBranch  *branch,
  * @error: a #GError for error reporting, or %NULL.
  *
  * Moves/renames an existing branch reference.
+ *
+ * Returns: (transfer full): the new branch.
  **/
-void
+GgitBranch *
 ggit_branch_move (GgitBranch       *branch,
                   const gchar      *new_branch_name,
                   GgitCreateFlags   flags,
                   GError          **error)
 {
+       git_reference *out;
        gboolean force;
        gint ret;
 
-       g_return_if_fail (GGIT_IS_BRANCH (branch));
-       g_return_if_fail (new_branch_name != NULL);
-       g_return_if_fail (error == NULL || *error == NULL);
+       g_return_val_if_fail (GGIT_IS_BRANCH (branch), NULL);
+       g_return_val_if_fail (new_branch_name != NULL, NULL);
+       g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
        force = flags & GGIT_CREATE_FORCE;
 
-       ret = git_branch_move (_ggit_native_get (branch),
+       ret = git_branch_move (&out,
+                              _ggit_native_get (branch),
                               new_branch_name,
                               force ? 1 : 0);
 
        if (ret != GIT_OK)
        {
                _ggit_error_set (error, ret);
+               return NULL;
        }
+
+       return _ggit_branch_wrap (out);
 }
 
 /**
diff --git a/libgit2-glib/ggit-branch.h b/libgit2-glib/ggit-branch.h
index fd61439..47c6ccb 100644
--- a/libgit2-glib/ggit-branch.h
+++ b/libgit2-glib/ggit-branch.h
@@ -56,7 +56,7 @@ GgitBranch        *_ggit_branch_wrap               (git_reference    *ref);
 void                ggit_branch_delete             (GgitBranch       *branch,
                                                     GError          **error);
 
-void                ggit_branch_move               (GgitBranch       *branch,
+GgitBranch         *ggit_branch_move               (GgitBranch       *branch,
                                                     const gchar      *new_branch_name,
                                                     GgitCreateFlags   flags,
                                                     GError          **error);
diff --git a/libgit2-glib/ggit-ref.c b/libgit2-glib/ggit-ref.c
index e689e67..86d0965 100644
--- a/libgit2-glib/ggit-ref.c
+++ b/libgit2-glib/ggit-ref.c
@@ -207,31 +207,40 @@ ggit_ref_get_owner (GgitRef *ref)
  * @target: The new target for the reference.
  * @error: a #GError for error reporting, or %NULL.
  *
- * Sets the symbolic target of @ref.
+ * Create a new reference with the same name as the given reference but a
+ * different symbolic target. The reference must be a symbolic reference,
+ * otherwise this will fail.
  *
- * The reference must be a symbolic reference, otherwise
- * this method will fail.
+ * The new reference will be written to disk, overwriting the given reference.
  *
- * The reference will be automatically updated in
- * memory and on disk.
+ * The target name will be checked for validity.
+ * See `ggit_ref_create_symbolic()` for rules about valid names.
+ *
+ * Returns: (transfer full): the newly created #GgitRef.
  */
-void
+GgitRef *
 ggit_ref_set_symbolic_target (GgitRef      *ref,
                               const gchar  *target,
                               GError      **error)
 {
+       git_reference *out;
        gint ret;
 
-       g_return_if_fail (ref != NULL);
-       g_return_if_fail (target != NULL);
-       g_return_if_fail (error == NULL || *error == NULL);
+       g_return_val_if_fail (ref != NULL, NULL);
+       g_return_val_if_fail (target != NULL, NULL);
+       g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
-       ret = git_reference_symbolic_set_target (_ggit_native_get (ref), target);
+       ret = git_reference_symbolic_set_target (&out,
+                                                _ggit_native_get (ref),
+                                                target);
 
        if (ret != GIT_OK)
        {
                _ggit_error_set (error, ret);
+               return NULL;
        }
+
+       return _ggit_ref_wrap (out);
 }
 
 /**
@@ -240,31 +249,37 @@ ggit_ref_set_symbolic_target (GgitRef      *ref,
  * @oid: a #GgitOId.
  * @error: a #GError for error reporting, or %NULL.
  *
- * Sets the OID target of @ref.
+ * Create a new reference with the same name as the given reference but a
+ * different OID target. The reference must be a direct reference, otherwise
+ * this will fail.
  *
- * The reference must be a direct reference, otherwise
- * this method will fail.
+ * The new reference will be written to disk, overwriting the given reference.
  *
- * The reference will be automatically updated in
- * memory and on disk.
+ * Returns: (transfer full): the newly created #GgitRef.
  */
-void
+GgitRef *
 ggit_ref_set_target (GgitRef  *ref,
                      GgitOId  *oid,
                      GError  **error)
 {
+       git_reference *out;
        gint ret;
 
-       g_return_if_fail (ref != NULL);
-       g_return_if_fail (oid != NULL);
-       g_return_if_fail (error == NULL || *error == NULL);
+       g_return_val_if_fail (ref != NULL, NULL);
+       g_return_val_if_fail (oid != NULL, NULL);
+       g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
-       ret = git_reference_set_target (_ggit_native_get (ref), _ggit_oid_get_oid (oid));
+       ret = git_reference_set_target (&out,
+                                       _ggit_native_get (ref),
+                                       _ggit_oid_get_oid (oid));
 
        if (ret != GIT_OK)
        {
                _ggit_error_set (error, ret);
+               return NULL;
        }
+
+       return _ggit_ref_wrap (out);
 }
 
 /**
@@ -274,35 +289,55 @@ ggit_ref_set_target (GgitRef  *ref,
  * @force: %TRUE to force the renaming.
  * @error: a #GError for error reporting, or %NULL.
  *
- * Renames @ref.
+ * Rename an existing reference.
  *
  * This method works for both direct and symbolic references.
- * The new name will be checked for validity and may be
- * modified into a normalized form.
  *
- * The refernece will be immediately renamed in-memory
- * and on disk.
+ * The new name will be checked for validity.
+ * See `ggit_ref_create_symbolic()` for rules about valid names.
+ *
+ * If not error, @ref will be deleted from disk and a
+ * new #GgitRef will be returned.
+ *
+ * The reference will be immediately renamed in-memory and on disk.
+ *
+ * If the `force` flag is not enabled, and there's already
+ * a reference with the given name, the renaming will fail.
+ *
+ * IMPORTANT:
+ * The user needs to write a proper reflog entry if the
+ * reflog is enabled for the repository. We only rename
+ * the reflog if it exists.
+ *
+ * Returns: (transfer full): a newly created #GgitRef.
  */
-void
+GgitRef *
 ggit_ref_rename (GgitRef     *ref,
                  const gchar *new_name,
                  gboolean     force,
                  GError     **error)
 {
+       git_reference *out;
        gint ret;
 
-       g_return_if_fail (ref != NULL);
-       g_return_if_fail (new_name != NULL);
-       g_return_if_fail (error == NULL || *error == NULL);
+       g_return_val_if_fail (ref != NULL, NULL);
+       g_return_val_if_fail (new_name != NULL, NULL);
+       g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
        force = (force != FALSE);
 
-       ret = git_reference_rename (_ggit_native_get (ref), new_name, force);
+       ret = git_reference_rename (&out,
+                                   _ggit_native_get (ref),
+                                   new_name,
+                                   force);
 
        if (ret != GIT_OK)
        {
                _ggit_error_set (error, ret);
+               return NULL;
        }
+
+       return _ggit_ref_wrap (out);
 }
 
 /**
@@ -367,10 +402,8 @@ ggit_ref_lookup (GgitRef  *ref,
                _ggit_error_set (error, ret);
                return NULL;
        }
-       else
-       {
-               return ggit_utils_create_real_object (obj, TRUE);
-       }
+
+       return ggit_utils_create_real_object (obj, TRUE);
 }
 
 /**
@@ -380,7 +413,7 @@ ggit_ref_lookup (GgitRef  *ref,
  *
  * Gets the #GgitReflog for @ref.
  *
- * Returns: the reflog.
+ * Returns: (transfer full): the reflog.
  */
 GgitReflog *
 ggit_ref_get_reflog (GgitRef  *ref,
@@ -413,7 +446,7 @@ ggit_ref_get_reflog (GgitRef  *ref,
  *
  * Creates a #GgitReflog with the given properties.
  *
- * Returns: the created reflog, or %NULL if error is set.
+ * Returns: (transfer full): the created reflog, or %NULL if error is set.
  */
 GgitReflog *
 ggit_ref_create_reflog (GgitRef        *ref,
diff --git a/libgit2-glib/ggit-ref.h b/libgit2-glib/ggit-ref.h
index 5406671..172b401 100644
--- a/libgit2-glib/ggit-ref.h
+++ b/libgit2-glib/ggit-ref.h
@@ -74,15 +74,15 @@ GgitRef        *ggit_ref_resolve            (GgitRef        *ref,
 
 GgitRepository *ggit_ref_get_owner          (GgitRef        *ref);
 
-void            ggit_ref_set_symbolic_target(GgitRef        *ref,
+GgitRef        *ggit_ref_set_symbolic_target(GgitRef        *ref,
                                              const gchar    *target,
                                              GError        **error);
 
-void            ggit_ref_set_target         (GgitRef        *ref,
+GgitRef        *ggit_ref_set_target         (GgitRef        *ref,
                                              GgitOId        *oid,
                                              GError        **error);
 
-void            ggit_ref_rename             (GgitRef        *ref,
+GgitRef        *ggit_ref_rename             (GgitRef        *ref,
                                              const gchar    *new_name,
                                              gboolean        force,
                                              GError        **error);
diff --git a/libgit2-glib/ggit-types.c b/libgit2-glib/ggit-types.c
index 4255029..bb531a6 100644
--- a/libgit2-glib/ggit-types.c
+++ b/libgit2-glib/ggit-types.c
@@ -102,8 +102,6 @@ ASSERT_ENUM (GGIT_FILEMODE_COMMIT, GIT_FILEMODE_COMMIT);
 ASSERT_ENUM (GGIT_REF_INVALID,  GIT_REF_INVALID);
 ASSERT_ENUM (GGIT_REF_OID,      GIT_REF_OID);
 ASSERT_ENUM (GGIT_REF_SYMBOLIC, GIT_REF_SYMBOLIC);
-ASSERT_ENUM (GGIT_REF_PACKED,   GIT_REF_PACKED);
-ASSERT_ENUM (GGIT_REF_HAS_PEEL, GIT_REF_HAS_PEEL);
 ASSERT_ENUM (GGIT_REF_LISTALL,  GIT_REF_LISTALL);
 
 
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index 30609d2..3efc358 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -442,8 +442,6 @@ typedef enum {
  * @GGIT_REF_INVALID: An invalid reference.
  * @GGIT_REF_OID: A reference which points at an object id.
  * @GGIT_REF_SYMBOLIC: A reference which points at another reference.
- * @GGIT_REF_PACKED: A reference which is packed.
- * @GGIT_REF_HAS_PEEL: Unused (as of 0.17.0).
  * @GGIT_REF_LISTALL: All reference types.
  *
  * Describes the type a reference is.
@@ -452,9 +450,7 @@ typedef enum {
        GGIT_REF_INVALID  = 0,
        GGIT_REF_OID      = 1,
        GGIT_REF_SYMBOLIC = 2,
-       GGIT_REF_PACKED   = 4,
-       GGIT_REF_HAS_PEEL = 8,
-       GGIT_REF_LISTALL  = GGIT_REF_OID | GGIT_REF_SYMBOLIC | GGIT_REF_PACKED
+       GGIT_REF_LISTALL  = GGIT_REF_OID | GGIT_REF_SYMBOLIC
 } GgitRefType;
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]