summaryrefslogtreecommitdiff
path: root/tests/status/renames.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/status/renames.c')
-rw-r--r--tests/status/renames.c90
1 files changed, 77 insertions, 13 deletions
diff --git a/tests/status/renames.c b/tests/status/renames.c
index 644791e69..2e61c3865 100644
--- a/tests/status/renames.c
+++ b/tests/status/renames.c
@@ -718,6 +718,70 @@ void test_status_renames__precomposed_unicode_toggle_is_rename(void)
#endif
}
+void test_status_renames__rename_threshold(void)
+{
+ git_index *index;
+ git_status_list *statuslist;
+ git_status_options opts = GIT_STATUS_OPTIONS_INIT;
+
+ _rename_helper(g_repo, "ikeepsix.txt", "newname.txt",
+ "Line 1\n" \
+ "Line 2\n" \
+ "Line 3\n" \
+ "Line 4\n" \
+ "Line 5\n" \
+ "Line 6\n" \
+ "Line 7\n" \
+ "Line 8\n" \
+ "Line 9\n"
+ );
+
+ opts.flags |= GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR;
+ opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED;
+
+ cl_git_pass(git_repository_index(&index, g_repo));
+
+ /* Default threshold */
+ {
+ struct status_entry expected[] = {
+ { GIT_STATUS_WT_RENAMED | GIT_STATUS_WT_MODIFIED, "ikeepsix.txt", "newname.txt" },
+ };
+
+ cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts));
+ check_status(statuslist, expected, 1);
+ git_status_list_free(statuslist);
+ }
+
+ /* Threshold set to 90 */
+ {
+ struct status_entry expected[] = {
+ { GIT_STATUS_WT_DELETED, "ikeepsix.txt", NULL },
+ { GIT_STATUS_WT_NEW, "newname.txt", NULL }
+ };
+
+ opts.rename_threshold = 90;
+
+ cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts));
+ check_status(statuslist, expected, 2);
+ git_status_list_free(statuslist);
+ }
+
+ /* Threshold set to 25 */
+ {
+ struct status_entry expected[] = {
+ { GIT_STATUS_WT_RENAMED | GIT_STATUS_WT_MODIFIED, "ikeepsix.txt", "newname.txt" },
+ };
+
+ opts.rename_threshold = 25;
+
+ cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts));
+ check_status(statuslist, expected, 1);
+ git_status_list_free(statuslist);
+ }
+
+ git_index_free(index);
+}
+
void test_status_renames__case_insensitive_h2i_and_i2wc(void)
{
git_status_list *statuslist;
@@ -728,39 +792,39 @@ void test_status_renames__case_insensitive_h2i_and_i2wc(void)
git_str path_to_edit = GIT_STR_INIT;
git_index *index;
git_strarray paths = { NULL, 0 };
-
+
struct status_entry expected[] = {
{ GIT_STATUS_INDEX_RENAMED | GIT_STATUS_WT_MODIFIED, "sixserving.txt", "sixserving-renamed.txt" },
{ GIT_STATUS_INDEX_DELETED, "Wow.txt", "Wow.txt" }
};
-
+
// Checkout the correct branch
checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_reference_lookup(&head, g_repo, "HEAD"));
cl_git_pass(git_reference_symbolic_set_target(
&test_branch, head, "refs/heads/case-insensitive-status", NULL));
cl_git_pass(git_checkout_head(g_repo, &checkout_opts));
-
+
cl_git_pass(git_repository_index(&index, g_repo));
-
-
+
+
// Rename sixserving.txt, delete Wow.txt, and stage those changes
rename_file(g_repo, "sixserving.txt", "sixserving-renamed.txt");
cl_git_pass(git_str_joinpath(
&path_to_delete, git_repository_workdir(g_repo), "Wow.txt"));
cl_git_rmfile(path_to_delete.ptr);
-
+
cl_git_pass(git_index_add_all(index, &paths, GIT_INDEX_ADD_FORCE, NULL, NULL));
cl_git_pass(git_index_write(index));
-
-
+
+
// Change content of sixserving-renamed.txt
cl_git_pass(git_str_joinpath(
&path_to_edit, git_repository_workdir(g_repo), "sixserving-renamed.txt"));
cl_git_append2file(path_to_edit.ptr, "New content\n");
-
-
+
+
// Run status
opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED;
opts.flags |= GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR;
@@ -770,12 +834,12 @@ void test_status_renames__case_insensitive_h2i_and_i2wc(void)
cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts));
check_status(statuslist, expected, 2);
git_status_list_free(statuslist);
-
+
git_index_free(index);
-
+
git_str_dispose(&path_to_delete);
git_str_dispose(&path_to_edit);
-
+
git_reference_free(head);
git_reference_free(test_branch);
}