{"thread":{"id":"29062","subject":"git merge strange result","startedAt":"2011-12-01T15:36:00Z","lastAt":"2011-12-01T18:50:32Z","messageCount":2,"participants":["Catalin(ux) M. BOIE","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"180204","messageId":"alpine.LFD.2.02.1112011733070.32682@mail.embedromix.ro","threadId":"29062","inReplyTo":null,"subject":"git merge strange result","fromName":"Catalin(ux) M. BOIE","fromEmail":"catab@embedromix.ro","sentAt":"2011-12-01T15:36:00Z","receivedAt":"2011-12-01T15:36:00Z","isPatch":false,"sender":{"key":"catab@embedromix.ro","avatar":null},"body":"Hello!\n\nBelow is a script that reproduce what a coleague of mine found.\nSeems that if in a branch we have a commit that is cherry-picked be \nmaster, than revert that commit in branch and merge branch in master, the \nrevert is ignored. Is it normal?\n\nThank you very much!\n\n#!/bin/bash\n\nset -e\n\nrm -rf buba1\nmkdir buba1\ncd buba1\n\ngit init\necho -e \"aaa\\nbbb\\nccc\" > file1\ngit add file1\ngit commit -m \"c1\"\n\necho \"Create branch b1...\"\ngit branch b1\necho\n\necho \"Create a bad fix...\"\nsed --in-place -e 's/bbb/bad line/' file1\ngit add file1\ngit commit -m \"bad commit\"\ncat file1\necho\n\necho \"Cherry pick on b1...\"\ngit checkout b1\ngit cherry-pick -x master\necho\n\necho \"Reverting on b1\"\ngit revert --no-edit b1\necho\n\necho \"Switch to master\"\ngit checkout master\necho\n\necho \"merge-base is `git merge-base --all master b1 | git name-rev --stdin`\"\necho\n\necho \"diff between master and b1...\"\ngit diff master b1\necho\n\necho \"Merge b1 in master\"\ngit merge --verbose --log b1\n\nif [ \"`grep bad file1`\" = \"\" ]; then\n \techo \"good!\"\nelse\n \techo \"bad!\"\nfi\n# it should prind \"good\"\n\n--\nCatalin(ux) M. BOIE\nhttp://kernel.embedromix.ro/\n"},{"id":"180211","messageId":"20111201185032.GA2873@sigill.intra.peff.net","threadId":"29062","inReplyTo":"alpine.LFD.2.02.1112011733070.32682@mail.embedromix.ro","subject":"Re: git merge strange result","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-12-01T18:50:32Z","receivedAt":"2011-12-01T18:50:32Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Dec 01, 2011 at 05:36:00PM +0200, Catalin(ux) M. BOIE wrote:\n\n> Below is a script that reproduce what a coleague of mine found.\n> Seems that if in a branch we have a commit that is cherry-picked be\n> master, than revert that commit in branch and merge branch in master,\n> the revert is ignored. Is it normal?\n\nYes, it's by design. When doing a merge, we look at three points: the\ntip of the current branch, the tip of the branch to be merged, and the\npoint at which history diverged (the \"merge base\"). We don't look\nindividually at the commits that happened between the merge base and\neach tip.\n\nThe non-conflicting case for a 3-way merge is that one side makes some\nchange, but the other side does nothing. In this case, we include the\nchange in the merge result. But remember that we are only looking at\nendpoints. So what the actual merge code sees is that one side's version\nof a file is identical to the merge base's version, and that the other\nside's version is now different.\n\nIn your case, one side makes the change, but then restores the original\nstate. So from the perspective of the merge code, no change happened at\nall on that side.\n\n-Peff\n"}]}