summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-06-24 11:39:59 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2015-06-24 11:39:59 -0400
commitba8fb7c46ac66e941f9452c9743c13fc2daaa85b (patch)
treeb4d32cd126c0b6310d6d20f2a81f70c551de719d
parent76633215d155dff2d5cda302aa868043b2c7090c (diff)
downloadlibgit2-ba8fb7c46ac66e941f9452c9743c13fc2daaa85b.tar.gz
diff::binary tests: empty diff when forced binary
Ensure that even when we're forcing a binary diff that we do not assume that there *is* a diff. There should be an empty diff for no change.
-rw-r--r--tests/diff/binary.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/diff/binary.c b/tests/diff/binary.c
index 90f2d5a06..6a5f3907b 100644
--- a/tests/diff/binary.c
+++ b/tests/diff/binary.c
@@ -269,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;