Re: git mv messed up file mapping if folders contain identical files
flat view
From: Bill Okara <hidden>
Date: 2016-06-15 23:08:26
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
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
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 [off-list ref] wrote:
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 [off-list ref] wrote:quoted
Bill Okara [off-list ref] writes:quoted
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.