Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-06-24 22:13:23 +0300
committerCarlos Martín Nieto <cmn@dwim.me>2015-06-24 22:13:23 +0300
commit9d5efab89f3e8579e1641c1d5c726a2dcdb8c014 (patch)
treea41300ad8d27e4c97a1d78cb4f72b9fd3fc0f8ec /tests
parentc2f274c69e48913308ae0a1ce9bd6f56104f2e6a (diff)
parent54077091c8cc12d83ad10b3252462c591c960de8 (diff)
Merge pull request #3254 from ethomson/diff-binary-patch
Handle binary DIFFABLEness properly
Diffstat (limited to 'tests')
-rw-r--r--tests/diff/binary.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/diff/binary.c b/tests/diff/binary.c
index 424a53e5f..6a5f3907b 100644
--- a/tests/diff/binary.c
+++ b/tests/diff/binary.c
@@ -1,5 +1,7 @@
#include "clar_libgit2.h"
+#include "git2/sys/diff.h"
+
#include "buffer.h"
#include "filebuf.h"
@@ -49,6 +51,11 @@ void test_patch(
cl_assert_equal_s(expected, actual.ptr);
+ git_buf_clear(&actual);
+ cl_git_pass(git_diff_print(diff, GIT_DIFF_FORMAT_PATCH, git_diff_print_callback__to_buf, &actual));
+
+ cl_assert_equal_s(expected, actual.ptr);
+
git_buf_free(&actual);
git_patch_free(patch);
git_diff_free(diff);
@@ -262,6 +269,36 @@ void test_diff_binary__delta_append(void)
git_index_free(index);
}
+void test_diff_binary__empty_for_no_diff(void)
+{
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
+ git_oid id;
+ git_commit *commit;
+ git_tree *tree;
+ git_diff *diff;
+ git_buf actual = GIT_BUF_INIT;
+ const char *expected = "";
+
+ opts.flags = GIT_DIFF_SHOW_BINARY | GIT_DIFF_FORCE_BINARY;
+ opts.id_abbrev = GIT_OID_HEXSZ;
+
+ repo = cl_git_sandbox_init("renames");
+
+ cl_git_pass(git_oid_fromstr(&id, "19dd32dfb1520a64e5bbaae8dce6ef423dfa2f13"));
+ cl_git_pass(git_commit_lookup(&commit, repo, &id));
+ cl_git_pass(git_commit_tree(&tree, commit));
+
+ cl_git_pass(git_diff_tree_to_tree(&diff, repo, tree, tree, &opts));
+ cl_git_pass(git_diff_print(diff, GIT_DIFF_FORMAT_PATCH, git_diff_print_callback__to_buf, &actual));
+
+ cl_assert_equal_s("", actual.ptr);
+
+ git_buf_free(&actual);
+ git_diff_free(diff);
+ git_commit_free(commit);
+ git_tree_free(tree);
+}
+
void test_diff_binary__index_to_workdir(void)
{
git_index *index;