{"thread":{"id":"37309","subject":"possibly a spurious conflict in a three way merge","startedAt":"2014-08-07T16:30:22Z","lastAt":"2014-08-07T18:52:43Z","messageCount":2,"participants":["meanlogin@gmail.com","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"247438","messageId":"53E3A99E.1090102@gmail.com","threadId":"37309","inReplyTo":null,"subject":"possibly a spurious conflict in a three way merge","fromName":"","fromEmail":"meanlogin@gmail.com","sentAt":"2014-08-07T16:30:22Z","receivedAt":"2014-08-07T16:30:22Z","isPatch":false,"sender":{"key":"meanlogin@gmail.com","avatar":null},"body":"git 2.0.4 on ubuntu 14.04 64\n\n1. new repo\n2. commit test.txt to master:\nline1\nline1\n\n3. branch and checkout branch1\n4. make and commit the following change to branch1:\n#line1\n#line2\n\n5. checkout master\n6. make and commit the following change to master:\nline1\n#line2\n\n7. merge branch1, git sees a conflict:\n<<<<<<< HEAD\nline1\n=======\n#line1\n >>>>>>> branch1\n#line2\n\nWhy?  The first line changed in branch1 but not in master so a 3 way \nmerge should take branch1 changes.  Beyond Compare ( used as a \nmergetool) does not flag any conflicts.\n"},{"id":"247449","messageId":"20140807185243.GE12427@google.com","threadId":"37309","inReplyTo":"53E3A99E.1090102@gmail.com","subject":"Re: possibly a spurious conflict in a three way merge","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2014-08-07T18:52:43Z","receivedAt":"2014-08-07T18:52:43Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nmeanlogin@gmail.com wrote:\n\n> 2. commit test.txt to master:\n> line1\n> line1\n>\n> 3. branch and checkout branch1\n> 4. make and commit the following change to branch1:\n> #line1\n> #line2\n>\n> 5. checkout master\n> 6. make and commit the following change to master:\n> line1\n> #line2\n>\n> 7. merge branch1, git sees a conflict:\n> <<<<<<< HEAD\n> line1\n> =======\n> #line1\n> >>>>>>> branch1\n> #line2\n>\n> Why?\n\nThanks for a clear example.  On branch1 you made the following change:\n\n (a) modify lines 1 and 2\n\nOn master, you made a different change:\n\n (b) just modify line 2\n\nThe changes touch the same chunk of lines and don't produce the same\nresult there.  Git is being conservative and letting you know that the\ntwo branches didn't agree about what line 1 should say.\n\nOn the other hand, if you had a larger files and on branch1 made the\nfollowing change:\n\n (a) modify lines 1 and 101\n\nand on master, you made a different change:\n\n (b) just modify line 101\n\nthen the changes are touching different parts of the code and are\nmerged independently.  The result would be a clean merge where lines 1\nand 101 are both modified.\n\nGit's conservatism can be helpful when working with code, where\nadjacent lines are likely to be affecting a single behavior and the\nconflict can help the operator to know to be extra careful.  It makes\nless sense for line-oriented input where every line is independent.\n\nIf you are often making changes to a line-oriented file, it may make\nsense to set up a custom merge driver to override git's merge behavior\nfor that file.  See 'Defining a custom merge driver' in\ngitattributes(5) for details about how that works.\n\nHope that helps,\nJonathan\n"}]}