{"thread":{"id":"22282","subject":"Branch merge bug","startedAt":"2010-01-19T07:22:58Z","lastAt":"2010-01-19T13:58:35Z","messageCount":5,"participants":["Ramkumar Ramachandra","Michael J Gruber","Andreas Krey"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"132085","messageId":"f3271551001182322p86a02d8p8b9ceb49e930d333@mail.gmail.com","threadId":"22282","inReplyTo":null,"subject":"Branch merge bug","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-01-19T07:22:58Z","receivedAt":"2010-01-19T07:22:58Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"A friend showed me this reduced test case. It seems to work fine with\nbzr and hg. Is this a git bug?\n\n>: git --version\ngit version 1.6.3.1\n>: git init\nInitialized empty Git repository in /Users/lut4rp/Code/tester/.git/\n>: echo asdjhaskd >fil\n>: git add fil\n>: git cm 'initial commit'\n[master (root-commit) 9983161] initial commit\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 fil\n>: git branch new\n>: git branch\n* master\n  new\n>: git mv fil fila\n>: git status\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#\trenamed:    fil -> fila\n#\n>: git cm 'renamed to fila'\n[master 9de0953] renamed to fila\n 1 files changed, 0 insertions(+), 0 deletions(-)\n rename fil => fila (100%)\n>: git co new\nSwitched to branch 'new'\n>: git rm fil\nrm 'fil'\n>: echo asjhdajkhsdkajhs >fila\n>: git add fila\n>: git cm 'renamed, heavily modified'\n[new 5914271] renamed, heavily modified\n 2 files changed, 2 insertions(+), 1 deletions(-)\n delete mode 100644 fil\n create mode 100644 fila\n>: git co master\nSwitched to branch 'master'\n>: git merge new\nCONFLICT (rename/delete): Rename fil->fila in HEAD and deleted in new\nAutomatic merge failed; fix conflicts and then commit the result.\n>: cat fila\nasdjhaskd                                  #### Still the master\nbranch's content, `merge` apparently did nothing.\n>: git show :2:fila\nasdjhaskd\n>: git show :3:fila\nfatal: ambiguous argument ':3:fila': unknown revision or path not in\nthe working tree.\nUse '--' to separate paths from revisions\n>: git show new:fila\nasjhdajkhsdkajhs\najksh askjdhaksdh kajshdk asd\n"},{"id":"132095","messageId":"4B55A080.7010705@drmicha.warpmail.net","threadId":"22282","inReplyTo":"f3271551001182322p86a02d8p8b9ceb49e930d333@mail.gmail.com","subject":"Re: Branch merge bug","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-01-19T12:07:28Z","receivedAt":"2010-01-19T12:07:28Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Ramkumar Ramachandra venit, vidit, dixit 19.01.2010 08:22:\n> A friend showed me this reduced test case. It seems to work fine with\n> bzr and hg. Is this a git bug?\n\nIt's not a bug, it's a feature. Git does not track renames. It tracks\ncontent and detects renames when necessary. Knowing that it is easy to\nconstruct examples on which git merge \"fails\", such as the one you present.\n\nA file which is changed completely is not a renamed file, it's a new one\nunder the same name. Whether the committer meant to create a new file\n(using the same name by accident or on purpose) or whether it is really\na heavily modified and renamed version - who knows? Git doesn't, and\ncannot, and it leaves that decision up to you.\n\nIf you really mean to modify and rename an existing file, then tell Git so:\n\ngit mv fil fila\ngit commit -m 'we need a new name'\n\ninstead of your 'git rm fil' will record your intentions (not only for\nGit, but also for everyone else reading your log, such as you a year\nfrom now) and will make the merge succeed.\n\nMichael\n"},{"id":"132097","messageId":"20100119123915.GB28667@inner.home.ulmdo.de","threadId":"22282","inReplyTo":"4B55A080.7010705@drmicha.warpmail.net","subject":"Re: Branch merge bug","fromName":"Andreas Krey","fromEmail":"a.krey@gmx.de","sentAt":"2010-01-19T12:39:15Z","receivedAt":"2010-01-19T12:39:15Z","isPatch":false,"sender":{"key":"a.krey@gmx.de","avatar":"https://avatars.githubusercontent.com/u/37810?v=4"},"body":"On Tue, 19 Jan 2010 13:07:28 +0000, Michael J Gruber wrote:\n...\n> If you really mean to modify and rename an existing file, then tell Git so:\n> \n> git mv fil fila\n> git commit -m 'we need a new name'\n> \n> instead of your 'git rm fil' will record your intentions (not only for\n> Git, but also for everyone else reading your log, such as you a year\n> from now) and will make the merge succeed.\n\nThe intention would only be known informally in the commit message,\nas 'git mv' just removes the old and adds the new file, and still\nleave the work to the rename detection.\n\nIndeed, changing\n  >: git rm fil\n  >: echo asjhdajkhsdkajhs >fila\n  >: git add fila\nto\n  >: git mv fil fila\n  >: echo asjhdajkhsdkajhs >fila\n  >: git add fila\nand even to\n  >: git mv fil fila\n  >: git cm 'other mv'\n  >: echo asjhdajkhsdkajhs >fila\n  >: git add fila\nstill gives the same rename/delete conflict because the rename\ndetection does not look at every single commit but only at\nthe total changes.\n\nWhich is actually good; when someone does\n\n  cp prog.c prog.cpp\n  git add prog.cpp && git commit\n  vi prog.cpp --make-compile-again && git commit -a\n  git rm prog.c && git commit\n\nit is still seen as a rename prog.c->prog.cpp even though both\nexisted in parallel for some commits.\n\nAndreas\n"},{"id":"132101","messageId":"f3271551001190522h37dd639k1352d54c1c07496f@mail.gmail.com","threadId":"22282","inReplyTo":"20100119123915.GB28667@inner.home.ulmdo.de","subject":"Re: Branch merge bug","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-01-19T13:22:16Z","receivedAt":"2010-01-19T13:22:16Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Right. Thanks for clearing that up for me.\n"},{"id":"132103","messageId":"4B55BA8B.5010600@drmicha.warpmail.net","threadId":"22282","inReplyTo":"20100119123915.GB28667@inner.home.ulmdo.de","subject":"Re: Branch merge bug","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-01-19T13:58:35Z","receivedAt":"2010-01-19T13:58:35Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Andreas Krey venit, vidit, dixit 19.01.2010 13:39:\n> On Tue, 19 Jan 2010 13:07:28 +0000, Michael J Gruber wrote:\n> ...\n>> If you really mean to modify and rename an existing file, then tell Git so:\n>>\n>> git mv fil fila\n>> git commit -m 'we need a new name'\n>>\n>> instead of your 'git rm fil' will record your intentions (not only for\n>> Git, but also for everyone else reading your log, such as you a year\n>> from now) and will make the merge succeed.\n> \n> The intention would only be known informally in the commit message,\n> as 'git mv' just removes the old and adds the new file, and still\n> leave the work to the rename detection.\n> \n> Indeed, changing\n>   >: git rm fil\n>   >: echo asjhdajkhsdkajhs >fila\n>   >: git add fila\n> to\n>   >: git mv fil fila\n>   >: echo asjhdajkhsdkajhs >fila\n>   >: git add fila\n> and even to\n>   >: git mv fil fila\n>   >: git cm 'other mv'\n>   >: echo asjhdajkhsdkajhs >fila\n>   >: git add fila\n> still gives the same rename/delete conflict because the rename\n> detection does not look at every single commit but only at\n> the total changes.\n\nWell, the solution I proposed (mv + commit rather than rm) certainly\nworks for me, I tested it before. I have diff.renames=copies in my\nconfig but I don't think it should matter.\n\nMichael\n"}]}