summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-24 15:25:01 -0700
committerRussell Belfer <rb@github.com>2014-04-24 15:25:01 -0700
commitf608f3bb274dbf413127ba352f48021ed538139e (patch)
tree159710db559a9b460f97f390ac9c8f910254f1ec
parent2334e3d8c33c639732e586ae8adfb65370523ab2 (diff)
downloadlibgit2-f608f3bb274dbf413127ba352f48021ed538139e.tar.gz
Test toggling core.precomposeunicode yields rename
There is an interesting difference with core Git here, though. Because libgit2 will do rename detection with the working directory, in the last case where the HEAD and the working directory both have the decomposed data and the index has the composed data, we generate a single status record with two renames whereas Git will generate one rename (head to index) and one untracked file.
-rw-r--r--tests/status/renames.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/status/renames.c b/tests/status/renames.c
index ab9cd7445..39fb801e2 100644
--- a/tests/status/renames.c
+++ b/tests/status/renames.c
@@ -636,4 +636,73 @@ void test_status_renames__precomposed_unicode_rename(void)
git_status_list_free(statuslist);
}
+void test_status_renames__precomposed_unicode_toggle_is_rename(void)
+{
+ git_status_list *statuslist;
+ git_status_options opts = GIT_STATUS_OPTIONS_INIT;
+ struct status_entry expected0[] = {
+ { GIT_STATUS_INDEX_RENAMED, "ikeepsix.txt", nfd },
+ };
+ struct status_entry expected1[] = {
+ { GIT_STATUS_WT_RENAMED, nfd, nfc },
+ };
+ struct status_entry expected2[] = {
+ { GIT_STATUS_INDEX_RENAMED, nfd, nfc },
+ };
+ struct status_entry expected3[] = {
+ { GIT_STATUS_INDEX_RENAMED | GIT_STATUS_WT_RENAMED, nfd, nfd },
+ };
+
+ cl_repo_set_bool(g_repo, "core.precomposeunicode", false);
+ rename_file(g_repo, "ikeepsix.txt", nfd);
+
+ {
+ git_index *index;
+ cl_git_pass(git_repository_index(&index, g_repo));
+ cl_git_pass(git_index_remove_bypath(index, "ikeepsix.txt"));
+ cl_git_pass(git_index_add_bypath(index, nfd));
+ cl_git_pass(git_index_write(index));
+ git_index_free(index);
+ }
+
+ opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED |
+ GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX |
+ GIT_STATUS_OPT_RENAMES_INDEX_TO_WORKDIR;
+
+ cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts));
+ check_status(statuslist, expected0, ARRAY_SIZE(expected0));
+ git_status_list_free(statuslist);
+
+ cl_repo_commit_from_index(NULL, g_repo, NULL, 0, "commit nfd");
+
+ cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts));
+ cl_assert_equal_sz(0, git_status_list_entrycount(statuslist));
+ git_status_list_free(statuslist);
+
+ cl_repo_set_bool(g_repo, "core.precomposeunicode", true);
+
+ cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts));
+ check_status(statuslist, expected1, ARRAY_SIZE(expected1));
+ git_status_list_free(statuslist);
+
+ {
+ git_index *index;
+ cl_git_pass(git_repository_index(&index, g_repo));
+ cl_git_pass(git_index_remove_bypath(index, nfd));
+ cl_git_pass(git_index_add_bypath(index, nfc));
+ cl_git_pass(git_index_write(index));
+ git_index_free(index);
+ }
+
+ cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts));
+ check_status(statuslist, expected2, ARRAY_SIZE(expected2));
+ git_status_list_free(statuslist);
+
+ cl_repo_set_bool(g_repo, "core.precomposeunicode", false);
+
+ cl_git_pass(git_status_list_new(&statuslist, g_repo, &opts));
+ check_status(statuslist, expected3, ARRAY_SIZE(expected3));
+ git_status_list_free(statuslist);
+}
+
#endif