[libgit2-glib] Fix diffing a blob to a buffer using GObject-Introspection
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Fix diffing a blob to a buffer using GObject-Introspection
- Date: Sat, 23 Aug 2014 13:50:52 +0000 (UTC)
commit 1abb137fed2e7c3002b78e46c7c84a423ad92a52
Author: Garrett Regier <garrettregier gmail com>
Date: Sat Aug 23 06:50:29 2014 -0700
Fix diffing a blob to a buffer using GObject-Introspection
Must use guint8 for a byte array not gchar, otherwise
Python can't use the method at all. This is already done
in various other places that provide the length.
libgit2-glib/ggit-diff.c | 13 ++++++++++---
libgit2-glib/ggit-diff.h | 4 ++--
2 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/libgit2-glib/ggit-diff.c b/libgit2-glib/ggit-diff.c
index 4ae9edf..d4889fc 100644
--- a/libgit2-glib/ggit-diff.c
+++ b/libgit2-glib/ggit-diff.c
@@ -18,6 +18,8 @@
* along with libgit2-glib. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <string.h>
+
#include <git2.h>
#include "ggit-diff.h"
@@ -757,8 +759,8 @@ ggit_diff_blobs (GgitBlob *old_blob,
void
ggit_diff_blob_to_buffer (GgitBlob *old_blob,
const gchar *old_as_path,
- const gchar *buffer,
- gsize buffer_len,
+ const guint8 *buffer,
+ gssize buffer_len,
const gchar *buffer_as_path,
GgitDiffOptions *diff_options,
GgitDiffFileCallback file_cb,
@@ -782,6 +784,11 @@ ggit_diff_blob_to_buffer (GgitBlob *old_blob,
wrapper_data.diff = NULL;
wrapper_data.encoding = NULL;
+ if (buffer_len == -1)
+ {
+ buffer_len = strlen((const gchar *) buffer);
+ }
+
if (file_cb != NULL)
{
real_file_cb = ggit_diff_file_callback_wrapper;
@@ -802,7 +809,7 @@ ggit_diff_blob_to_buffer (GgitBlob *old_blob,
ret = git_diff_blob_to_buffer (old_blob ? _ggit_native_get (old_blob) : NULL,
old_as_path,
- buffer,
+ (const gchar *) buffer,
buffer_len,
buffer_as_path,
(git_diff_options *) gdiff_options,
diff --git a/libgit2-glib/ggit-diff.h b/libgit2-glib/ggit-diff.h
index fac5e44..94a6016 100644
--- a/libgit2-glib/ggit-diff.h
+++ b/libgit2-glib/ggit-diff.h
@@ -113,8 +113,8 @@ void ggit_diff_blobs (GgitBlob *old_b
void ggit_diff_blob_to_buffer (GgitBlob *old_blob,
const gchar *old_as_path,
- const gchar *buffer,
- gsize buffer_len,
+ const guint8 *buffer,
+ gssize buffer_len,
const gchar *buffer_as_path,
GgitDiffOptions *diff_options,
GgitDiffFileCallback file_cb,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]