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

git mv messed up file mapping if folders contain identical files

From
BOBill Okara <billokara@gmail.com>
Date
Feb 24, 2016, 23:38 UTC
Message-ID
<CADsr5c_Hk34KBN06dM9Hk5HPW9-Mt3eZLMgvyes8sSgxCA-k0w@mail.gmail.com>
Hi,

I noticed the following 'git mv' issue with: git version 2.6.4

If there are identical files in different subfolders, 'git mv' the
root folder (and/or each file individually) will mess up the file path
mapping. that is, if having identical 'content.txt' file under
gitmvtest
    |--demo/content.txt
    |--dev/content.txt
    |--prod/content.txt

after doing the "git mv gitmvtest/resources gitmvtest/src/main/resources", the 'git status' will show:

renamed: gitmvtest/resources/demo/content.txt -> gitmvtest/src/main/resources/demo/content.txt renamed: gitmvtest/resources/prod/content.txt -> gitmvtest/src/main/resources/dev/content.txt <== NOTE: wrongly mapped the prod/content.txt to dev/content.txt renamed: gitmvtest/resources/dev/content.txt -> gitmvtest/src/main/resources/prod/content.txt <== NOTE: wrongly mapped the dev/content.txt to prod/content.txt

I tried running 'git mv' on each file individually, got the same problem:
> git mv gitmvtest/resources/demo/content.txt gitmvtest/src/main/resources/demo/content.txt
> git mv gitmvtest/resources/dev/content.txt gitmvtest/src/main/resources/dev/content.txt
> git mv gitmvtest/resources/prod/content.txt gitmvtest/src/main/resources/prod/content.txt
> git status

renamed: gitmvtest/resources/demo/content.txt -> gitmvtest/src/main/resources/demo/content.txt renamed: gitmvtest/resources/prod/content.txt -> gitmvtest/src/main/resources/dev/content.txt <== WRONG renamed: gitmvtest/resources/dev/content.txt -> gitmvtest/src/main/resources/prod/content.txt <== WRONG

NOTE: ======= if modified the content.txt in the 3 folders to contain different data, then repeating the above 'git mv' will produce correct result,

renamed: gitmvtest/resources/demo/content.txt -> gitmvtest/src/main/resources/demo/content.txt <== CORRECT renamed: gitmvtest/resources/dev/content.txt -> gitmvtest/src/main/resources/dev/content.txt <== CORRECT renamed: gitmvtest/resources/prod/content.txt -> gitmvtest/src/main/resources/prod/content.txt <== CORRECT

just want to see if this is a bug, user error (on my end), or??

Thanks, Bill

Next: Junio C Hamano
Message 1 of 9 in “git mv messed up file mapping if folders contain identical files”
  1. Bill OkaraFeb 24, 2016
  2. Junio C HamanoFeb 24, 2016
  3. Bill OkaraFeb 24, 2016
  4. Bill OkaraFeb 25, 2016
  5. Kevin DaudtFeb 25, 2016
  6. Stefan BellerFeb 25, 2016
  7. Bill OkaraFeb 25, 2016
  8. SZEDER GáborFeb 26, 2016
  9. Bill OkaraFeb 26, 2016

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.