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

RE: Trouble merging renamed but identical files - CONFLICT (rename/rename)

From
Jason Pyeron <jpyeron@pdinc.us>
Date
Jun 28, 2014, 09:46 UTC
Message-ID
<E569F92DE6554654A2133A162EDB688E@black>
In-Reply-To
<CEAC9BE9F83B4CD0AFD73BBAC8A54232@black>
Show 158 quoted lines
> -----Original Message-----
> From: Jason Pyeron
> Sent: Friday, June 27, 2014 20:42
> To: 'git'
> Cc: 'Phil Hord'
> Subject: RE: Trouble merging renamed but identical files - 
> CONFLICT (rename/rename)
> 
> > -----Original Message-----
> > From: Jason Pyeron 
> > Sent: Friday, June 27, 2014 18:39
> > 
> > > -----Original Message-----
> > > From: Phil Hord [mailto:phil.hord@gmail.com] 
> > > Sent: Friday, June 27, 2014 17:46
> > > To: Jason Pyeron
> > > Cc: git
> > > Subject: Re: Trouble merging renamed but identical files - 
> > > CONFLICT (rename/rename)
> > > 
> > > On Fri, Jun 27, 2014 at 4:47 PM, Jason Pyeron 
> > > <jpyeron@pdinc.us> wrote:
> > > > There are two identical files from the same original 
> > > parent, but both were
> > > > renamed in their own branches. One branch moved the file to 
> > > a new folder, the
> > > > other renamed the file in the same folder.
> > > 
> > > You have not stated what you think the issue is.  You have 
> > only stated
> > > the setup.
> > 
> > Thanks, I could have said it better. 
> > 
> > I think that git should understand that I have moved a file 
> > in path only (the tree object containing the file's entry 
> > change, but not the entry it self) and that the branch from 
> > which I want to merge back (with common ancestry) has renamed 
> > the file in the same path ( the tree object is unchanged, but 
> > the entry is) such that the object is re-parented and renamed 
> > in that path.
> > 
> > How can this be done in git or if it cannot what are the 
> > chalenges to patching git for this issue.
> > 
> > git cat-file -p b60070f4d0879e277f44d174a163bbb292325fea # 
> > tree d8df83fc6714aab1fc1df061fcb03410e1dab1e5
> > git cat-file -p d8df83fc6714aab1fc1df061fcb03410e1dab1e5 # 
> > 040000 tree 68bb8a223284e0f5057421217a5965128bf1d51a    src
> > git cat-file -p 68bb8a223284e0f5057421217a5965128bf1d51a # 
> > 100644 blob 25c7d3b12bced67046359ba1e7945f82a2640147    
> TrueCrypt.sln
> > 
> > git cat-file -p a0c84ff28f356bcb8b872a9c65a2e9bff97b3f68 # 
> > tree 7f82a6c46f19931c3c40d44dc196cbfab7feaa72
> > git cat-file -p 7f82a6c46f19931c3c40d44dc196cbfab7feaa72 # 
> > 100644 blob 25c7d3b12bced67046359ba1e7945f82a2640147    
> CipherShed.sln
> > 
> > > 
> > > 
> > > I suppose you want Git to merge without conflict in the 
> end, though,
> > > based on your script.  Is that right?
> > > 
> > > 
> > > > Steps to reproduce the issue:
> > > > git init
> > > > git fetch https://github.com/pdinc-oss/CipherShed.git
> > > > git fetch https://github.com/srguglielmo/CipherShed.git
> > > > git checkout -b test b60070f4d0879e277f44d174a163bbb292325fea
> > > > git merge a0c84ff28f356bcb8b872a9c65a2e9bff97b3f68
> > > >
> > > > CONFLICT (rename/rename): Rename 
> > > "TrueCrypt.sln"->"src/TrueCrypt.sln" in branch
> > > > "HEAD" rename "TrueCrypt.sln"->"CipherShed.sln" in
> > > > "a0c84ff28f356bcb8b872a9c65a2e9bff97b3f68"
> > > 
> > > Git seems to be doing the correct thing here.
> > > 
> > > 
> > > > git reset --hard b60070f4d0879e277f44d174a163bbb292325fea
> > > > git mv src/TrueCrypt.sln src/CipherShed.sln
> > > > git commit -m 'renamed to be congruent with a0c84ff'
> > > > git merge a0c84ff28f356bcb8b872a9c65a2e9bff97b3f68
> > > >
> > > > Sill get a CONFLICT (rename/rename): Rename
> > > > "TrueCrypt.sln"->"src/CipherShed.sln" in branch "HEAD" rename
> > > > "TrueCrypt.sln"->"CipherShed.sln" in 
> > > "a0c84ff28f356bcb8b872a9c65a2e9bff97b3f68"
> > > 
> > > Git seems to be doing the correct thing here, too.
> > > 
> > > > I will have many more to come, any suggestions?
> > > 
> > > Maybe you meant to move the renamed file to the same 
> folder where it
> > > exists in the merge target.  I do not get a conflict when 
> I do that.
> > 
> > Are you saying I should git mv src/TrueCrypt.sln CipherShed.sln ?
> > 
> > Then it will be in the wrong path as intended.
> > 
> > > 
> > >    git reset --hard b60070f4d0879e277f44d174a163bbb292325fea
> > >    git mv src/TrueCrypt.sln CipherShed.sln
> > >    git commit -m 'renamed to be congruent with a0c84ff'
> > >    git merge a0c84ff28f356bcb8b872a9c65a2e9bff97b3f68
> > > 
> > > No conflict (on that file, anyway).
> > 
> > Agreed, but not the desired end state.
> 
> Sorry for the http://pastebin.com/1R68v6jt (changes the merge to
> 1ca13ed2271d60ba93d40bcc8db17ced8545f172, and manually 
> reconciles the merge),
> but it was too long to be readable in the email.
> 
> git blame HEAD -- src/Main/Forms/CipherShed.fbp | cut -c 1-8 
> | sort -u 
> 
> Gives: 
> ac812aa3
> b50a2fb1
> 
> git blame b60070f4d0879e277f44d174a163bbb292325fea --
> src/Main/Forms/TrueCrypt.fbp | cut -c 1-8 | sort -u
> 
> Gives: 
> 07b2176f
> 0eb8b4fa
> 12c94add
> a17c95a3
> a757b4d4
> cac6cd14
> d0a9dfa8
> d94128a9
> e6b1437a
> f1bb489c
> 
> If I use cherry pick (vs merge), I can maintain the big 
> history in b60070f, but
> loose the small history in 1ca13ed
> 
>       [test]
>       /     \
>      /       \
> [b60070f] [1ca13ed]
>     |         |
>     |         |
> [65efd37]     |
>     |    \    |
>     |     \   |
> [d8da778] [39ebb06]
> 
> How do I maintain all the history including the (line) 
> changes in 1ca13ed?
# http://pastebin.com/TuqhYubH 
# do the cerry picks, then...
git merge $(echo 'Merge of 1ca13ed2271d60ba93d40bcc8db17ced8545f172 branch -
rebranding' |\
   git commit-tree -p HEAD -p rebranding \
     $(git cat-file -p HEAD | grep ^tree | sed -e 's/^tree //') )

Perfect results. This does not seem like this should be the "right" way to do it.

Instead of git merge rebranding, which gives CONFLICT (rename/rename).... Automatic merge failed; fix conflicts and then commit the result. Followed by bad blame lines.

-Jason
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.
 
Previous: Jason PyeronNext: Phil Hord
Message 6 of 12 in “Trouble merging renamed but identical files - CONFLICT (rename/rename)”
  1. Jason PyeronJun 27, 2014
  2. Phil HordJun 27, 2014
  3. Jason PyeronJun 27, 2014
  4. Phil HordJun 29, 2014
  5. Jason PyeronJun 28, 2014
  6. Jason PyeronJun 28, 2014
  7. Phil HordJun 29, 2014
  8. Phil HordJun 29, 2014
  9. Jason PyeronJun 29, 2014
  10. Phil HordJun 29, 2014
  11. Jason PyeronJun 29, 2014
  12. Phil HordJun 30, 2014

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.