Thread (1 message) 1 message, 1 author, 2021-01-06

Re: [PATCH/RFC v1 1/1] git mv foo FOO ; git mv foo bar gave an assert

From: Junio C Hamano <hidden>
Date: 2021-01-06 23:52:37

tboegi@web.de writes:
From: Torsten Bögershausen <redacted>

The following sequence, on a case-insensitive file system,
(strictly speeking with core.ignorecase=true)
leads to an assertion, and leaves .git/index.lock behind.
"an assertion failure" you mean.
git init
echo foo >foo
git add foo
git mv foo FOO
git mv foo bar

This regression was introduced in Commit 9b906af657,
"git-mv: improve error message for conflicted file"

Don't check if the case-insensitive version is in the index.
In the sense of 9b906af657 supply the user with a more helpful message.

This fixes
https://github.com/git-for-windows/git/issues/2920

Reported-By: Dan Moseley <redacted>
Signed-off-by: Torsten Bögershausen <redacted>
---

Note:
There is an ongoing effort to replace cache_file_exists() with
index_file_exists().  So this patch may need to be re-done.
Thanks for a heads-up.
quoted hunk
Note2: @Dan Moseley: Do you want to continue with this work ?

builtin/mv.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/builtin/mv.c b/builtin/mv.c
index 7dac714af9..8572a5dae0 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -221,8 +221,11 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				}
 				argc += last - first;
 			}
-		} else if (!(ce = cache_file_exists(src, length, ignore_case))) {
-			bad = _("not under version control");
+		} else if (!(ce = cache_file_exists(src, length, 0))) {
+			if (cache_file_exists(src, length, ignore_case))
+				bad = _("not under version control (upper/lower mixup)");
+			else
+				bad = _("not under version control");
 		} else if (ce_stage(ce)) {
 			bad = _("conflicted");
 		} else if (lstat(dst, &st) == 0 &&
--
2.28.0.97.gdc04167d37
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help