]> git.proxmox.com Git - libgit2.git/commitdiff
checkout test: ignore unstaged case-changing renames
authorEdward Thomson <ethomson@microsoft.com>
Fri, 27 Mar 2015 19:33:44 +0000 (15:33 -0400)
committerEdward Thomson <ethomson@edwardthomson.com>
Mon, 4 May 2015 12:18:25 +0000 (07:18 -0500)
On Windows, you might sloppily rewrite a file (or have a sloppy
text editor that does it for you) and accidentally change its
case.  (eg, "README" -> "readme").  Git ignores this accidental
case changing rename during checkout and will happily write the
new content to the file despite the name change.  We should, too.

tests/checkout/tree.c

index 3973d9320213db2eec966e07f3784a6644f11627..46e8b0f900dae1b90e4e30938e4b27efc6e9028a 100644 (file)
@@ -1327,3 +1327,25 @@ void test_checkout_tree__safe_proceeds_if_no_index(void)
        git_object_free(obj);
 }
 
+void test_checkout_tree__ignores_unstaged_casechange(void)
+{
+       git_reference *orig_ref, *br2_ref;
+       git_commit *orig, *br2;
+       git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
+
+       checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
+
+       cl_git_pass(git_reference_lookup_resolved(&orig_ref, g_repo, "HEAD", 100));
+       cl_git_pass(git_commit_lookup(&orig, g_repo, git_reference_target(orig_ref)));
+       cl_git_pass(git_reset(g_repo, (git_object *)orig, GIT_RESET_HARD, NULL));
+
+       cl_rename("testrepo/branch_file.txt", "testrepo/Branch_File.txt");
+
+       cl_git_pass(git_reference_lookup_resolved(&br2_ref, g_repo, "refs/heads/br2", 100));
+       cl_git_pass(git_commit_lookup(&br2, g_repo, git_reference_target(br2_ref)));
+
+       cl_git_pass(git_checkout_tree(g_repo, (const git_object *)br2, &checkout_opts));
+
+       git_commit_free(orig);
+       git_reference_free(orig_ref);
+}