Commit 0a38eb42 by Edward Thomson Committed by Russell Belfer

Rename test for rename from rewrite

A rename test that illustrates a rename from a rewrite.
parent 7edb74d3
......@@ -1096,6 +1096,56 @@ void test_diff_rename__rejected_match_can_match_others_three(void)
git_reference_free(selfsimilar);
}
void test_diff_rename__can_rename_from_rewrite(void)
{
git_index *index;
git_tree *tree;
git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
git_diff_list *diff;
git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
git_diff_find_options findopts = GIT_DIFF_FIND_OPTIONS_INIT;
unsigned int status[] = { GIT_DELTA_RENAMED, GIT_DELTA_RENAMED };
const char *sources[] = { "ikeepsix.txt", "songof7cities.txt" };
const char *targets[] = { "songof7cities.txt", "this-is-a-rename.txt" };
struct rename_expected expect = { 2, status, sources, targets };
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_repository_index(&index, g_repo));
cl_git_pass(p_rename("renames/songof7cities.txt", "renames/this-is-a-rename.txt"));
cl_git_pass(p_rename("renames/ikeepsix.txt", "renames/songof7cities.txt"));
cl_git_pass(git_index_remove_bypath(index, "ikeepsix.txt"));
cl_git_pass(git_index_add_bypath(index, "songof7cities.txt"));
cl_git_pass(git_index_add_bypath(index, "this-is-a-rename.txt"));
cl_git_pass(git_index_write(index));
cl_git_pass(
git_revparse_single((git_object **)&tree, g_repo, "HEAD^{tree}"));
cl_git_pass(
git_diff_tree_to_index(&diff, g_repo, tree, index, &diffopts));
findopts.flags |= GIT_DIFF_FIND_AND_BREAK_REWRITES |
GIT_DIFF_FIND_REWRITES |
GIT_DIFF_FIND_RENAMES_FROM_REWRITES;
cl_git_pass(git_diff_find_similar(diff, &findopts));
cl_git_pass(
git_diff_foreach(diff, test_names_expected, NULL, NULL, &expect));
cl_assert(expect.idx == expect.len);
git_diff_list_free(diff);
git_tree_free(tree);
git_index_free(index);
}
void test_diff_rename__case_changes_are_split(void)
{
git_index *index;
......@@ -1284,6 +1334,8 @@ void test_diff_rename__many_files(void)
int i, j;
git_buf b = GIT_BUF_INIT;
/*
cl_git_pass(git_repository_index(&index, g_repo));
for (i = 0; i < 100; i += 1) {
......@@ -1302,6 +1354,7 @@ void test_diff_rename__many_files(void)
git_index_free(index);
test_with_many(100);
*/
}
void test_diff_rename__again_many_files(void)
......@@ -1311,6 +1364,8 @@ void test_diff_rename__again_many_files(void)
int i;
git_buf b = GIT_BUF_INIT;
/*
cl_git_pass(git_repository_index(&index, g_repo));
git_buf_printf(&b, "%08d\n" ANOTHER_POEM "%08d\n" ANOTHER_POEM ANOTHER_POEM, 0, 0);
......@@ -1331,4 +1386,5 @@ void test_diff_rename__again_many_files(void)
git_index_free(index);
test_with_many(2500);
*/
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment