{"thread":{"id":"29996","subject":"Strange git merge behaviour with empty branches","startedAt":"2012-03-19T18:53:49Z","lastAt":"2012-03-19T19:51:17Z","messageCount":2,"participants":["Will Deacon","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"187267","messageId":"20120319185349.GH12789@mudshark.cambridge.arm.com","threadId":"29996","inReplyTo":null,"subject":"Strange git merge behaviour with empty branches","fromName":"Will Deacon","fromEmail":"will.deacon@arm.com","sentAt":"2012-03-19T18:53:49Z","receivedAt":"2012-03-19T18:53:49Z","isPatch":false,"sender":{"key":"will.deacon@arm.com","avatar":null},"body":"Hello git people,\n\nI'm seeing some strange behaviour with git merge and wondered if you could\nhelp me to understand what's going on.\n\nSay I have a master branch tracking upstream and a few local branches based\noff that:\n\n$ git branch\n  master\n  foo\n  bar\n  baz\n\nFurthermore, let's say that both foo and bar are currently at master (that\nis, they have no additional commits) but baz does have changes committed on\ntop of master.\n\nNow, if I make an integration branch:\n\n$ git checkout master -b integration\n\nI can then merge foo, bar and baz into this:\n\n$ git merge foo bar baz\n\nwhich works fine. However, specifying the non-empty branch first does:\n\n$ git merge baz foo bar\nAlready up-to-date.\n\nand the changes from baz are not merged in. For extra weirdness, if you\nhave another non-empty branch (qux) and do:\n\n$ git merge baz foo bar qux\n\nThen you end up with a branch that *doesn't* contain baz, *does* contain\nqux and has a weird looking merge-commit message that just reads \"baz\"!\n\nNow, I appreciate that merging in empty branches might seem weird but it's\nsometimes useful if you have scripts that take a set of known branches, merge\nthem and then do a build.\n\nAny thoughts?\n\nCheers,\n\nWill\n"},{"id":"187272","messageId":"7vvcm09xoq.fsf@alter.siamese.dyndns.org","threadId":"29996","inReplyTo":"20120319185349.GH12789@mudshark.cambridge.arm.com","subject":"Re: Strange git merge behaviour with empty branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-19T19:51:17Z","receivedAt":"2012-03-19T19:51:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Will Deacon <will.deacon@arm.com> writes:\n\n> Any thoughts?\n\nWhat is recorded in Octopus merges is a rather torn issue.  The original\nmotivation was to allow recording anything the user throws at us, even\nthough some are ancestors of others, without reducing them to the minimum\nset of parents that are necessary to represent the full history, because\nthat is after all what the user wanted to do. You see some of that there.\n\nOn the other hand, there was an edict from the original maintainer that we\nshouldn't record useless merge parents, so there were some changes in that\ndirection to cull obviously redundant parents from the parent list.\n\nBut over time, novelty of Octopus merges waned, and nobody serious uses it\nfor real work these days, except when bored and being curious, playing\naround and seeing what it does.\n\nAn advice for an end-user is \"Don't throw meaningless parents at\nOctopus. It will do whatever it does, and the only guarantee you are\ngetting is that it does not record wrong parents, it may omit obviously\nredundant parents, and it will never discard an independent parent.\"\n\nAn advice for a developer is to update it to make sure only the\nindependent parents are recorded; \"show-branch --independent\" may be a\ngood tool to compute them\n"}]}