[libgit2-glib] Bind ggit_patch_new_from_blobs
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Bind ggit_patch_new_from_blobs
- Date: Fri, 22 Nov 2013 12:22:55 +0000 (UTC)
commit 2f71d05c25ff09cc417fab56edb29d4454acbdbe
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Fri Nov 22 13:21:13 2013 +0100
Bind ggit_patch_new_from_blobs
libgit2-glib/ggit-patch.c | 49 +++++++++++++++++++++++++++++++++++++++++++++
libgit2-glib/ggit-patch.h | 7 ++++++
2 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-patch.c b/libgit2-glib/ggit-patch.c
index 2d13289..127c5ba 100644
--- a/libgit2-glib/ggit-patch.c
+++ b/libgit2-glib/ggit-patch.c
@@ -20,6 +20,7 @@
#include "ggit-patch.h"
#include "ggit-error.h"
+#include "ggit-diff-options.h"
struct _GgitPatch
{
@@ -116,6 +117,54 @@ ggit_patch_new_from_diff (GgitDiff *diff,
}
/**
+ * ggit_patch_new_from_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,
+ * @new_blob: (allow-none): a #GgitBlob to diff to.
+ * @new_as_path: (allow-none): treat @new_blob as if it had this filename, or %NULL,
+ * @diff_options: (allow-none): a #GgitDiffOptions, or %NULL.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Directly generate a patch from the difference between two blobs.
+ *
+ * This is just like ggit_diff_blobs() except it generates a patch object
+ * for the difference instead of directly making callbacks. You can use the
+ * standard ggit_patch accessor functions to read the patch data, and
+ * you must call ggit_patch_unref on the patch when done.
+ */
+GgitPatch *
+ggit_patch_new_from_blobs (GgitBlob *old_blob,
+ const gchar *old_as_path,
+ GgitBlob *new_blob,
+ const gchar *new_as_path,
+ GgitDiffOptions *diff_options,
+ GError **error)
+{
+ gint ret;
+ const git_diff_options *gdiff_options;
+ git_patch *patch;
+
+ g_return_if_fail (error == NULL || *error == NULL);
+
+ gdiff_options = _ggit_diff_options_get_diff_options (diff_options);
+
+ ret = git_patch_from_blobs (&patch,
+ old_blob ? _ggit_native_get (old_blob) : NULL,
+ old_as_path,
+ new_blob ? _ggit_native_get (new_blob) : NULL,
+ new_as_path,
+ (git_diff_options *) gdiff_options);
+
+ 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 dfbed77..bf6547f 100644
--- a/libgit2-glib/ggit-patch.h
+++ b/libgit2-glib/ggit-patch.h
@@ -43,6 +43,13 @@ GgitPatch *ggit_patch_new_from_diff (GgitDiff *diff,
gsize idx,
GError **error);
+GgitPatch *ggit_patch_new_from_blobs (GgitBlob *old_blob,
+ const gchar *old_as_path,
+ GgitBlob *new_blob,
+ const gchar *new_as_path,
+ GgitDiffOptions *diff_options,
+ 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]