mv: allow renaming to fix case on case insensitive filesystems

"git mv hello.txt Hello.txt" on a case insensitive filesystem always triggers "destination already exists" error, because these two names refer to the same path from the filesystem's point of view, and requires the user to give "--force" when correcting the case of the path recorded in the index and in the next commit. Detect this case and allow it without requiring "--force". Signed-off-by: David Turner <dturner@twitter.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

David Turner committed May 8, 2014 at 10:23 UTC baa37bff9a845471754d3f47957d58a6ccc30058
2 files changed +3 -2
builtin/mv.c
+2 -1
@@ -202,7 +202,8 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
202 }
203 } else if (cache_name_pos(src, length) < 0)
204 bad = _("not under version control");
205 - else if (lstat(dst, &st) == 0) {
205 + else if (lstat(dst, &st) == 0 &&
206 + (!ignore_case || strcasecmp(src, dst))) {
207 bad = _("destination exists");
208 if (force) {
209 /*
t/t6039-merge-ignorecase.sh
+1 -1
@@ -35,7 +35,7 @@ test_expect_success 'merge with case-changing rename on both sides' '
35 git reset --hard baseline &&
36 git branch -D with-camel &&
37 git checkout -b with-camel &&
38 - git mv --force TestCase testcase &&
38 + git mv TestCase testcase &&
39 git commit -m "recase on branch" &&
40 >foo &&
41 git add foo &&