summaryrefslogtreecommitdiff
path: root/tests/index/rename.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-08-07 12:43:49 -0500
committerEdward Thomson <ethomson@microsoft.com>2015-09-08 11:34:00 -0400
commita32bc85e84090299ab9ba56b2d8f1761b7d91873 (patch)
tree8a2075c3cec24b8f06b514da84b51ac3db6e131f /tests/index/rename.c
parent280adb3f942a1ce4f4939b7058209d0cd0467062 (diff)
downloadlibgit2-a32bc85e84090299ab9ba56b2d8f1761b7d91873.tar.gz
git_index_add: allow case changing renames
On case insensitive platforms, allow `git_index_add` to provide a new path for an existing index entry. Previously, we would maintain the case in an index entry without the ability to change it (except by removing an entry and re-adding it.) Higher-level functions (like `git_index_add_bypath` and `git_index_add_frombuffers`) continue to keep the old path for easier usage.
Diffstat (limited to 'tests/index/rename.c')
-rw-r--r--tests/index/rename.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/index/rename.c b/tests/index/rename.c
index dd3cfa732..ebaa9b740 100644
--- a/tests/index/rename.c
+++ b/tests/index/rename.c
@@ -48,3 +48,34 @@ void test_index_rename__single_file(void)
cl_fixture_cleanup("rename");
}
+
+void test_index_rename__casechanging(void)
+{
+ git_repository *repo;
+ git_index *index;
+ const git_index_entry *entry;
+ git_index_entry new = {{0}};
+
+ p_mkdir("rename", 0700);
+
+ cl_git_pass(git_repository_init(&repo, "./rename", 0));
+ cl_git_pass(git_repository_index(&index, repo));
+
+ cl_git_mkfile("./rename/lame.name.txt", "new_file\n");
+
+ cl_git_pass(git_index_add_bypath(index, "lame.name.txt"));
+ cl_assert_equal_i(1, git_index_entrycount(index));
+ cl_assert((entry = git_index_get_bypath(index, "lame.name.txt", 0)));
+
+ memcpy(&new, entry, sizeof(git_index_entry));
+ new.path = "LAME.name.TXT";
+
+ cl_git_pass(git_index_add(index, &new));
+ cl_assert((entry = git_index_get_bypath(index, "LAME.name.TXT", 0)));
+
+ if (cl_repo_get_bool(repo, "core.ignorecase"))
+ cl_assert_equal_i(1, git_index_entrycount(index));
+ else
+ cl_assert_equal_i(2, git_index_entrycount(index));
+}
+