summaryrefslogtreecommitdiff
path: root/tests-clar/diff/rename.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2013-03-11 11:18:00 -0500
committerEdward Thomson <ethomson@microsoft.com>2013-03-11 12:47:01 -0500
commitaa408cbfc4940e05cb7843383264623e45737bb9 (patch)
tree02210552d4b2edd791a769b9854755bc000de2e6 /tests-clar/diff/rename.c
parentd768f9add943e0ca220c81d7ffa29fc3215cd119 (diff)
downloadlibgit2-aa408cbfc4940e05cb7843383264623e45737bb9.tar.gz
handle small files in similarity metrics
Diffstat (limited to 'tests-clar/diff/rename.c')
-rw-r--r--tests-clar/diff/rename.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests-clar/diff/rename.c b/tests-clar/diff/rename.c
index ae766408c..5a8af93bb 100644
--- a/tests-clar/diff/rename.c
+++ b/tests-clar/diff/rename.c
@@ -352,6 +352,39 @@ void test_diff_rename__not_exact_match(void)
git_tree_free(new_tree);
}
+void test_diff_rename__handles_small_files(void)
+{
+ const char *tree_sha = "2bc7f351d20b53f1c72c16c4b036e491c478c49a";
+ git_index *index;
+ git_tree *tree;
+ git_diff_list *diff;
+ git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
+ git_diff_find_options opts = GIT_DIFF_FIND_OPTIONS_INIT;
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+
+ tree = resolve_commit_oid_to_tree(g_repo, tree_sha);
+
+ cl_git_rewritefile("renames/songof7cities.txt", "single line\n");
+ cl_git_pass(git_index_add_bypath(index, "songof7cities.txt"));
+
+ cl_git_rewritefile("renames/untimely.txt", "untimely\n");
+ cl_git_pass(git_index_add_bypath(index, "untimely.txt"));
+
+ /* Tests that we can invoke find_similar on small files
+ * and that the GIT_EBUFS (too small) error code is not
+ * propagated to the caller.
+ */
+ cl_git_pass(git_diff_tree_to_index(&diff, g_repo, tree, index, &diffopts));
+
+ opts.flags = GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES | GIT_DIFF_FIND_AND_BREAK_REWRITES;
+ cl_git_pass(git_diff_find_similar(diff, &opts));
+
+ git_diff_list_free(diff);
+ git_tree_free(tree);
+ git_index_free(index);
+}
+
void test_diff_rename__working_directory_changes(void)
{
/* let's rewrite some files in the working directory on demand */