git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: [EXTERNAL] [PATCH v2 1/1] git mv foo FOO ; git mv foo bar gave an assert

From
DMDan Moseley <dan.moseley@microsoft.com>
Date
Mar 1, 2021, 20:23 UTC
Message-ID
<BYAPR21MB1158CDD04067369BB367474CE09A9@BYAPR21MB1158.namprd21.prod.outlook.com>
In-Reply-To
<20210301170425.12154-1-tboegi@web.de>
Show 45 quoted lines
> From: Torsten Bögershausen <tboegi@web.de>
> 
> 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.
> 
> 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"
> 
> The bugfix is to change the "file exist case-insensitive in the index"
> into the correct "file exist (case-sensitive) in the index".
> This avoids the "assert".
> 
> Reported-By: Dan Moseley <Dan.Moseley@microsoft.com>
> 
> This fixes
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgit-for-windows%2Fgit%2Fissues%2F2920&amp;data=04%7C01%7CDan.Moseley%40microsoft.com%7Cb659ba5925c543bcc3e708d8dcd41268%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637502150683596627%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=%2BLjQf5NooTUgOKbsyn10XCFIAgMw9v%2BKlhx8kDD6%2BIg%3D&amp;reserved=0
> 
> Signed-off-by: Torsten Bögershausen <tboegi@web.de>
> ---
>  builtin/mv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/builtin/mv.c b/builtin/mv.c
> index 7dac714af9..3fccdcb645 100644
> --- a/builtin/mv.c
> +++ b/builtin/mv.c
> @@ -221,7 +221,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
>  				}
>  				argc += last - first;
>  			}
> -		} else if (!(ce = cache_file_exists(src, length, ignore_case))) {
> +		} else if (!(ce = cache_file_exists(src, length, 0))) {
>  			bad = _("not under version control");
>  		} else if (ce_stage(ce)) {
>  			bad = _("conflicted");
> --
> 2.30.0.155.g66e871b664
>

Thank you Thorsten. This makes sense to me. Do you want to add a test? I believe this is what I had in my original patch, that worked pretty well:

diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index 63d5f41a12..5c7fee9bd8 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -152,6 +152,14 @@ test_expect_success \
     'move into "."' \
     'git mv path1/path2/ .'

+test_expect_success \
+    'fail to move file already in index under different cased name' \
+    'echo 1 > foo &&
+     git add foo &&
+     git commit -m add_file -- foo &&
+     git mv foo FOO &&
+     test_expect_code 128 git mv foo BAR'
+
 test_expect_success "Michael Cassar's test case" '
        rm -fr .git papers partA &&
        git init &&
--
2.25.1
Previous: Junio C HamanoNext: Junio C Hamano
Message 12 of 13 in “git-mv: fix git mv bug with case insensitive fs”
  1. git-mv: fix git mv bug with case insensitive fsDan Moseley, Dec 29, 2020
  2. Torsten BögershausenDec 31, 2020
  3. Junio C HamanoJan 6, 2021
  4. 1/1 git mv foo FOO ; git mv foo bar gave an asserttboegi@web.de, Jan 6, 2021
  5. Junio C HamanoJan 6, 2021
  6. 1/1 git mv foo FOO ; git mv foo bar gave an asserttboegi@web.de, Mar 1, 2021
  7. Junio C HamanoMar 1, 2021
  8. Chris TorekMar 1, 2021
  9. Junio C HamanoMar 1, 2021
  10. 1/1 git mv foo FOO ; git mv foo bar gave an asserttboegi@web.de, Mar 1, 2021
  11. Junio C HamanoMar 1, 2021
  12. Dan MoseleyMar 1, 2021
  13. Junio C HamanoMar 1, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.