summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-01-06 07:42:36 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2022-01-06 07:42:36 -0500
commite2e3f3e4cde7871f86eabacc6a639439b70a8fc7 (patch)
tree2deb688b19ace5a96955287eefdc6a902a85d137
parentdb3572b730e5f0976833b4edb1ee07b764deaa95 (diff)
parent9faa9199026258b084ecd292d9b93ac56b81ee94 (diff)
downloadlibgit2-e2e3f3e4cde7871f86eabacc6a639439b70a8fc7.tar.gz
Merge branch 'status'
-rw-r--r--src/diff_tform.c2
-rw-r--r--tests/resources/renames/.gitted/objects/41/a766bb079e18ff6a24571831bd751168799a021
-rw-r--r--tests/resources/renames/.gitted/objects/ba/8b004914491b129b4feff51b5fd8553b8e8156bin0 -> 191 bytes
-rw-r--r--tests/resources/renames/.gitted/objects/e5/6d39ca6d946331aa79c9c443d46c8a6ed4f550bin0 -> 36 bytes
-rw-r--r--tests/resources/renames/.gitted/refs/heads/case-insensitive-status1
-rw-r--r--tests/status/renames.c91
6 files changed, 79 insertions, 16 deletions
diff --git a/src/diff_tform.c b/src/diff_tform.c
index d14134071..f9836d245 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -375,7 +375,7 @@ static int apply_splits_and_deletes(
size_t i;
git_diff_delta *delta;
- if (git_vector_init(&onto, expected_size, git_diff_delta__cmp) < 0)
+ if (git_vector_init(&onto, expected_size, diff->deltas._cmp) < 0)
return -1;
/* build new delta list without TO_DELETE and splitting TO_SPLIT */
diff --git a/tests/resources/renames/.gitted/objects/41/a766bb079e18ff6a24571831bd751168799a02 b/tests/resources/renames/.gitted/objects/41/a766bb079e18ff6a24571831bd751168799a02
new file mode 100644
index 000000000..4bd7592d5
--- /dev/null
+++ b/tests/resources/renames/.gitted/objects/41/a766bb079e18ff6a24571831bd751168799a02
@@ -0,0 +1 @@
+xKN0DYGD#!CK=8pzZ[ԫ{`g4:3`N?E Bp8=wL, `ubΜh#VSᣬop}%smǃc}2nNKDo%xE'I׃kO]J]A0 ƃ ZʟƆ_[ \ No newline at end of file
diff --git a/tests/resources/renames/.gitted/objects/ba/8b004914491b129b4feff51b5fd8553b8e8156 b/tests/resources/renames/.gitted/objects/ba/8b004914491b129b4feff51b5fd8553b8e8156
new file mode 100644
index 000000000..c61d650ce
--- /dev/null
+++ b/tests/resources/renames/.gitted/objects/ba/8b004914491b129b4feff51b5fd8553b8e8156
Binary files differ
diff --git a/tests/resources/renames/.gitted/objects/e5/6d39ca6d946331aa79c9c443d46c8a6ed4f550 b/tests/resources/renames/.gitted/objects/e5/6d39ca6d946331aa79c9c443d46c8a6ed4f550
new file mode 100644
index 000000000..d6deb188d
--- /dev/null
+++ b/tests/resources/renames/.gitted/objects/e5/6d39ca6d946331aa79c9c443d46c8a6ed4f550
Binary files differ
diff --git a/tests/resources/renames/.gitted/refs/heads/case-insensitive-status b/tests/resources/renames/.gitted/refs/heads/case-insensitive-status
new file mode 100644
index 000000000..5a92127e7
--- /dev/null
+++ b/tests/resources/renames/.gitted/refs/heads/case-insensitive-status
@@ -0,0 +1 @@
+41a766bb079e18ff6a24571831bd751168799a02
diff --git a/tests/status/renames.c b/tests/status/renames.c
index d17a94ca7..d5cf87d07 100644
--- a/tests/status/renames.c
+++ b/tests/status/renames.c
@@ -723,7 +723,7 @@ 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" \
@@ -735,49 +735,110 @@ void test_status_renames__rename_threshold(void)
"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
+
+ /* 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
+
+ /* 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
+
+ /* 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;
+ git_status_options opts = GIT_STATUS_OPTIONS_INIT;
+ git_reference *head, *test_branch;
+ git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+ git_str path_to_delete = GIT_STR_INIT;
+ 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;
+ opts.flags |= GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX;
+ opts.flags |= GIT_STATUS_OPT_SORT_CASE_INSENSITIVELY;
+
+ 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);
+}