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

Re: git mv messed up file mapping if folders contain identical files

From
Stefan Beller <sbeller@google.com>
Date
Feb 25, 2016, 13:56 UTC
Message-ID
<CAGZ79kZApquSRaY_BtHrqfvuWmtYuPjeshmT-oW6T8Z7atYdFQ@mail.gmail.com>
In-Reply-To
<20160225114958.GC15324@ikke.info>
On Thu, Feb 25, 2016 at 3:49 AM, Kevin Daudt <me@ikke.info> wrote:
Show 60 quoted lines
> On Wed, Feb 24, 2016 at 04:38:11PM -0700, Bill Okara wrote:
>> 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??
>>
>
> This looks like the same issue as submodule--helper list has:
> http://article.gmane.org/gmane.comp.version-control.git/287227

The submodule--helper is not called from within git-mv, so it may be a similar but not the same issue. ;)

Looking through the code, the pathspec is not treated according to the newest style convention, I think it is one of the last places where the pathspec internals are poked with, instead of using parse_parsespec && match_parsespec. (That said it is very old hence often tested code in the wild. old code != bad code)

Stefan
Previous: Kevin DaudtNext: Bill Okara
Message 6 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.