[libgit2-glib] diff: allow to pass NULL callbacks to not use them and NULL blobs



commit f18c395550ed4074466fc5ac183502eb7daa161c
Author: Ignacio Casal Quinteiro <ignacio casal nice-software com>
Date:   Mon Jan 14 19:43:16 2013 +0100

    diff: allow to pass NULL callbacks to not use them and NULL blobs

 libgit2-glib/ggit-diff.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/libgit2-glib/ggit-diff.c b/libgit2-glib/ggit-diff.c
index e74cb6f..9252b08 100644
--- a/libgit2-glib/ggit-diff.c
+++ b/libgit2-glib/ggit-diff.c
@@ -507,7 +507,6 @@ ggit_diff_blobs (GgitDiffOptions       *diff_options,
 	git_diff_hunk_cb real_hunk_cb = NULL;
 	git_diff_data_cb real_line_cb = NULL;
 
-	g_return_if_fail (file_cb != NULL && hunk_cb != NULL && line_cb != NULL);
 	g_return_if_fail (error == NULL || *error == NULL);
 
 	gdiff_options = _ggit_diff_options_get_diff_options (diff_options);
@@ -532,8 +531,8 @@ ggit_diff_blobs (GgitDiffOptions       *diff_options,
 		wrapper_data.line_cb = line_cb;
 	}
 
-	ret = git_diff_blobs (_ggit_native_get (old_blob),
-	                      _ggit_native_get (new_blob),
+	ret = git_diff_blobs (old_blob ? _ggit_native_get (old_blob) : NULL,
+	                      new_blob ? _ggit_native_get (new_blob) : NULL,
 	                      (git_diff_options *) gdiff_options,
 	                      real_file_cb, real_hunk_cb, real_line_cb,
 	                      &wrapper_data);
@@ -579,7 +578,6 @@ ggit_diff_blob_to_buffer (GgitDiffOptions       *diff_options,
 	git_diff_hunk_cb real_hunk_cb = NULL;
 	git_diff_data_cb real_line_cb = NULL;
 
-	g_return_if_fail (file_cb != NULL && hunk_cb != NULL && line_cb != NULL);
 	g_return_if_fail (error == NULL || *error == NULL);
 
 	gdiff_options = _ggit_diff_options_get_diff_options (diff_options);
@@ -604,7 +602,7 @@ ggit_diff_blob_to_buffer (GgitDiffOptions       *diff_options,
 		wrapper_data.line_cb = line_cb;
 	}
 
-	ret = git_diff_blob_to_buffer (_ggit_native_get (old_blob),
+	ret = git_diff_blob_to_buffer (old_blob ? _ggit_native_get (old_blob) : NULL,
 	                               buffer,
 	                               buffer_len,
 	                               (git_diff_options *) gdiff_options,



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