[libgit2-glib] diff: diff_get_patch is replaced now by patch_new_from_diff



commit 22b83f5d574ed70967eb9ad8dbcd0d001887e047
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Fri Nov 22 10:35:01 2013 +0100

    diff: diff_get_patch is replaced now by patch_new_from_diff

 libgit2-glib/ggit-diff.c  |   58 ---------------------------------------------
 libgit2-glib/ggit-diff.h  |    6 ----
 libgit2-glib/ggit-patch.c |   35 +++++++++++++++++++++++++++
 libgit2-glib/ggit-patch.h |    4 +++
 4 files changed, 39 insertions(+), 64 deletions(-)
---
diff --git a/libgit2-glib/ggit-diff.c b/libgit2-glib/ggit-diff.c
index 9dfcb29..aa82eb6 100644
--- a/libgit2-glib/ggit-diff.c
+++ b/libgit2-glib/ggit-diff.c
@@ -459,64 +459,6 @@ ggit_diff_get_num_deltas (GgitDiff *diff)
 }
 
 /**
- * ggit_diff_get_patch:
- * @diff: a #GgitDiff.
- * @idx: index into @diff.
- * @patch: (allow-none) (out): a #GgitPatch or %NULL.
- * @delta: (allow-none) (out): a #GgitDiffDelta or %NULL.
- * @error: a #GError for error reporting, or %NULL.
- *
- * Gets the diff delta and patch for an entry in @diff.
- *
- * The #GgitPatch is a newly created object contains the text diffs
- * for the delta.  You have to call git_diff_patch_unref() when you are
- * done with it.  You can use the patch object to loop over all the hunks
- * and lines in the diff of the one delta.
- *
- * For an unchanged file or a binary file, no #GgitPatch will be
- * created, the output will be set to %NULL, and the `binary` flag will be
- * set true in @delta.
- *
- * It is okay to pass %NULL for either of the output parameters; if you pass
- * %NULL for @patch, then the text diff will not be calculated.
- */
-void
-ggit_diff_get_patch (GgitDiff       *diff,
-                     gsize           idx,
-                     GgitPatch     **patch,
-                     GgitDiffDelta **delta,
-                     GError        **error)
-{
-       gint ret;
-       const git_diff_delta *delta_out;
-       git_diff_patch *patch_out = NULL;
-
-       g_return_if_fail (GGIT_IS_DIFF (diff));
-       g_return_if_fail (error == NULL || *error == NULL);
-
-       ret = git_diff_get_patch (patch ? &patch_out : NULL,
-                                 delta ? &delta_out : NULL,
-                                 _ggit_native_get (diff),
-                                 idx);
-
-       if (ret != GIT_OK)
-       {
-               _ggit_error_set (error, ret);
-               return;
-       }
-
-       if (patch && patch_out)
-       {
-               *patch = _ggit_patch_wrap (patch_out);
-       }
-
-       if (delta)
-       {
-               *delta = _ggit_diff_delta_wrap (delta_out);
-       }
-}
-
-/**
  * ggit_diff_blobs:
  * @old_blob: (allow-none): a #GgitBlob to diff from.
  * @old_as_path: (allow-none): treat @old_blob as if it had this filename, or %NULL,
diff --git a/libgit2-glib/ggit-diff.h b/libgit2-glib/ggit-diff.h
index 34c9c71..17d7c27 100644
--- a/libgit2-glib/ggit-diff.h
+++ b/libgit2-glib/ggit-diff.h
@@ -99,12 +99,6 @@ void           ggit_diff_print                     (GgitDiff              *diff,
 
 gint           ggit_diff_get_num_deltas            (GgitDiff              *diff);
 
-void           ggit_diff_get_patch                 (GgitDiff              *diff,
-                                                    gsize                  idx,
-                                                    GgitPatch            **patch,
-                                                    GgitDiffDelta        **delta,
-                                                    GError               **error);
-
 void           ggit_diff_blobs                     (GgitBlob              *old_blob,
                                                     const gchar           *old_as_path,
                                                     GgitBlob              *new_blob,
diff --git a/libgit2-glib/ggit-patch.c b/libgit2-glib/ggit-patch.c
index 9880577..2d13289 100644
--- a/libgit2-glib/ggit-patch.c
+++ b/libgit2-glib/ggit-patch.c
@@ -81,6 +81,41 @@ ggit_patch_unref (GgitPatch *patch)
 }
 
 /**
+ * ggit_patch_new_from_diff:
+ * @diff: a #GgitDiff.
+ * @idx: index into diff list.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * The #GgitPatch is a newly created object contains the text diffs
+ * for the delta.  You have to call ggit_patch_unref() when you are
+ * done with it.  You can use the patch object to loop over all the hunks
+ * and lines in the diff of the one delta.
+ *
+ * Returns: (transfer full): a newly created #GgitPatch.
+ */
+GgitPatch *
+ggit_patch_new_from_diff (GgitDiff  *diff,
+                          gsize      idx,
+                          GError   **error)
+{
+       git_patch *patch;
+       gint ret;
+
+       g_return_val_if_fail (GGIT_IS_DIFF (diff), NULL);
+       g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+       ret = git_patch_from_diff (&patch, _ggit_native_get (diff), idx);
+
+       if (ret != GIT_OK)
+       {
+               _ggit_error_set (error, ret);
+               return NULL;
+       }
+
+       return _ggit_patch_wrap (patch);
+}
+
+/**
  * ggit_patch_to_string:
  * @patch: a #GgitPatch.
  * @error: a #GError for error reporting, or %NULL.
diff --git a/libgit2-glib/ggit-patch.h b/libgit2-glib/ggit-patch.h
index 7484261..dfbed77 100644
--- a/libgit2-glib/ggit-patch.h
+++ b/libgit2-glib/ggit-patch.h
@@ -39,6 +39,10 @@ GgitPatch       *ggit_patch_ref             (GgitPatch      *patch);
 
 void             ggit_patch_unref           (GgitPatch      *patch);
 
+GgitPatch       *ggit_patch_new_from_diff   (GgitDiff       *diff,
+                                             gsize           idx,
+                                             GError        **error);
+
 gchar           *ggit_patch_to_string       (GgitPatch      *patch,
                                              GError        **error);
 


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