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
BOBill Okara <billokara@gmail.com>
Date
Feb 25, 2016, 00:03 UTC
Message-ID
<CADsr5c_DyzTNcPg9aZ6TJse0i0o=4LMz7_-QXtOpfnLhF3cKLw@mail.gmail.com>
In-Reply-To
<CADsr5c8akqt7tsgptuDqCyt2JW8ie9js5eFt7oxXxDxtGMLJFA@mail.gmail.com>

following are the steps to help illustrate the issue. its actually quite common to have projects include identical placeholder files before update/refactoring...

// Create in master branch
Show 15 quoted lines
> mkdir gittest
> cd gittest
> init
> mkdir -p gitmvtest/resources
> mkdir -p gitmvtest/resources/demo
> mkdir -p gitmvtest/resources/dev
> mkdir -p gitmvtest/resources/prod
> cd gitmvtest/resources/demo/
> echo 'This is the line that contains the common content’ >> content.txt
> cd ..
> cp demo/content.txt dev/.
> cp demo/content.txt prod/.
> cd ../..
> git add .
> git commit -m "master content.txt first commit"
# change to a new branch
> git checkout -b newTestBranch
> mkdir -p gitmvtest/src/main
> git mv gitmvtest/resources gitmvtest/src/main/.
> git commit -m "newTestBranch: mv resources to src/main/resources"
[newTestBranch 5faed26] newTestBranch: mv resources to src/main/resources
 3 files changed, 0 insertions(+), 0 deletions(-)
 rename gitmvtest/{resources/prod => src/main/resources/demo}/content.txt (100%)
 rename gitmvtest/{ => src/main}/resources/dev/content.txt (100%)
 rename gitmvtest/{resources/demo => src/main/resources/prod}/content.txt (100%)
// Change back to master and update the 3 files
Show 6 quoted lines
> git checkout master
> echo 'this is DEMO content' >> gitmvtest/resources/demo/content.txt
> echo 'this is DEV content' >> gitmvtest/resources/dev/content.txt
> echo 'this is PROD content' >> gitmvtest/resources/prod/content.txt
> git add .
> git commit -m "master: update content.txt to include parent folder name"
[master 18d85f9] master: update content.txt to include parent folder name
 3 files changed, 3 insertions(+)
// Change back to the new branch and merge from master
> git checkout newTestBranch
> git merge master

Auto-merging gitmvtest/src/main/resources/prod/content.txt Auto-merging gitmvtest/src/main/resources/dev/content.txt Auto-merging gitmvtest/src/main/resources/demo/content.txt

Merge made by the 'recursive' strategy.
 gitmvtest/src/main/resources/demo/content.txt | 1 +
 gitmvtest/src/main/resources/dev/content.txt  | 1 +
 gitmvtest/src/main/resources/prod/content.txt | 1 +
 3 files changed, 3 insertions(+)

// SEE the ERROR: //demo/content.txt wrongly merged with data from prod/content.txt

> cat gitmvtest/src/main/resources/demo/content.txt

This is the line that contains the common content this is PROD content

On Wed, Feb 24, 2016 at 4:51 PM, Bill Okara <billokara@gmail.com> wrote:
Show 19 quoted lines
> it actually does matter in the following scenario:
>
> 1) master branch has identical content.txt files in the folder structure
> 2) do the git mv in a new branch
> 3) master branch updated the context.txt to contain new data (more
> relevant to the containing folder)
> 4) new branch need to merge the updates from master
>
> after the merge, demo/content.txt in the new path would contain
> updates from dev/content.txt from master...
>
> On Wed, Feb 24, 2016 at 4:39 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Bill Okara <billokara@gmail.com> writes:
>>
>>> just want to see if this is a bug, user error (on my end), or??
>>
>> Not a bug, not a user error, just "it does not matter", I think.
>>
>>
Previous: Bill OkaraNext: Kevin Daudt
Message 4 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.