{"thread":{"id":"4136","subject":"Howto get the merge-base ?","startedAt":"2006-05-14T17:21:01Z","lastAt":"2006-05-14T18:40:40Z","messageCount":5,"participants":["Bertrand Jacquin","Junio C Hamano","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"19916","messageId":"4fb292fa0605141021r20cefaa0he592b9c713ede333@mail.gmail.com","threadId":"4136","inReplyTo":null,"subject":"Howto get the merge-base ?","fromName":"Bertrand Jacquin","fromEmail":"beber.mailing@gmail.com","sentAt":"2006-05-14T17:21:01Z","receivedAt":"2006-05-14T17:21:01Z","isPatch":false,"sender":{"key":"beber.mailing@gmail.com","avatar":null},"body":"Hi,\n\nI'm trying to know which commit it the parent of a merge.\nFor exemple if I do that :\n\n   o Merge\n  / \\\n /   \\\n |   |\n |   o Commit D\n |   |\n |   o Commit C\n |   |\n o   | Commit B\n \\  /\n  \\/\n  o Commit A\n  |\n  o Init\n\nHow could I know that ``Commit A'' is the merge-base of ``Merge'' ?\n\nI try to get this git-merge-base but result is strange and quiet\nmysterious as he return me always second args I passed to. I'm using\ngit 1.3.2\n\n-- \nBeber\n#e.fr@freenode\n"},{"id":"19919","messageId":"7v3bfc33hm.fsf@assigned-by-dhcp.cox.net","threadId":"4136","inReplyTo":"4fb292fa0605141021r20cefaa0he592b9c713ede333@mail.gmail.com","subject":"Re: Howto get the merge-base ?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-14T17:44:53Z","receivedAt":"2006-05-14T17:44:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Bertrand Jacquin\" <beber.mailing@gmail.com> writes:\n\n> I'm trying to know which commit it the parent of a merge.\n> For exemple if I do that :\n>\n>   o Merge\n>  / \\\n> /   \\\n> |   |\n> |   o Commit D\n> |   |\n> |   o Commit C\n> |   |\n> o   | Commit B\n> \\  /\n>  \\/\n>  o Commit A\n>  |\n>  o Init\n>\n> How could I know that ``Commit A'' is the merge-base of ``Merge'' ?\n\n> I try to get this git-merge-base but result is strange and quiet\n> mysterious as he return me always second args I passed to.\n\nIt is mysterious to me because you did not say what you gave as\narguments ;-).\n\nIf I am reading you correctly, you already have a \"Merge\"\ncommit, made by you or somebody else, and are trying to figure\nout where the merge base was.  If that is the case:\n\n\tgit-merge-base Merge^1 Merge^2\n\nin other words\n\n\tgit-merge-base CommitB CommitD        \n\nis what you are looking for?\n\nBut what do you need that information for?  To reproduce\nsomebody else's merge?\n"},{"id":"19921","messageId":"4fb292fa0605141104j6c73c1eao5a8eeea9ad1b6282@mail.gmail.com","threadId":"4136","inReplyTo":"7v3bfc33hm.fsf@assigned-by-dhcp.cox.net","subject":"Re: Howto get the merge-base ?","fromName":"Bertrand Jacquin","fromEmail":"beber.mailing@gmail.com","sentAt":"2006-05-14T18:04:45Z","receivedAt":"2006-05-14T18:04:45Z","isPatch":false,"sender":{"key":"beber.mailing@gmail.com","avatar":null},"body":"On 5/14/06, Junio C Hamano <junkio@cox.net> wrote:\n> \"Bertrand Jacquin\" <beber.mailing@gmail.com> writes:\n>\n> > I'm trying to know which commit it the parent of a merge.\n> > For exemple if I do that :\n> >\n> >   o Merge\n> >  / \\\n> > /   \\\n> > |   |\n> > |   o Commit D\n> > |   |\n> > |   o Commit C\n> > |   |\n> > o   | Commit B\n> > \\  /\n> >  \\/\n> >  o Commit A\n> >  |\n> >  o Init\n> >\n> > How could I know that ``Commit A'' is the merge-base of ``Merge'' ?\n>\n> > I try to get this git-merge-base but result is strange and quiet\n> > mysterious as he return me always second args I passed to.\n>\n> It is mysterious to me because you did not say what you gave as\n> arguments ;-).\n\nI was using git-merge-base ``merge-ish'' ``comit-ish''. Docs about it\nis atrocious so was trying many but not the one good. Blam me.\n\n> If I am reading you correctly, you already have a \"Merge\"\n> commit, made by you or somebody else, and are trying to figure\n> out where the merge base was.  If that is the case:\n>\n>         git-merge-base Merge^1 Merge^2\n>\n> in other words\n>\n>         git-merge-base CommitB CommitD\n\nThat's ok :)\n\n> is what you are looking for?\n\nYes ! Thanks :)\n\n> But what do you need that information for?  To reproduce\n> somebody else's merge?\n\nNo, that's just on the following of git-send-mail-commit.sh thread (or\nsomething near). To make a readable merge mail with diffstat and\nsummury.\n\n-- \nBeber\n#e.fr@freenode\n"},{"id":"19922","messageId":"7vu07s1nn3.fsf@assigned-by-dhcp.cox.net","threadId":"4136","inReplyTo":"4fb292fa0605141104j6c73c1eao5a8eeea9ad1b6282@mail.gmail.com","subject":"Re: Howto get the merge-base ?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-14T18:12:32Z","receivedAt":"2006-05-14T18:12:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Bertrand Jacquin\" <beber.mailing@gmail.com> writes:\n\n> On 5/14/06, Junio C Hamano <junkio@cox.net> wrote:\n>> \"Bertrand Jacquin\" <beber.mailing@gmail.com> writes:\n>>\n>> > I'm trying to know which commit it the parent of a merge.\n>> > For exemple if I do that :\n>> >\n>> >   o Merge\n>> >  / \\\n>> > /   \\\n>> > |   |\n>> > |   o Commit D\n>> > |   |\n>> > |   o Commit C\n>> > |   |\n>> > o   | Commit B\n>> > \\  /\n>> >  \\/\n>> >  o Commit A\n>> >  |\n>> >  o Init\n>> >\n> No, that's just on the following of git-send-mail-commit.sh thread (or\n> something near). To make a readable merge mail with diffstat and\n> summury.\n\nFor that you do not want merge-base.  If your mainline was A-B\nand you merged a side branch B-C-D with the merge, then to\npeople who tracked your head (that's the audience of \"merge\nmail\", I presume) they just need to see:\n\n\tgit diff --stat M^1..M\n\tgit rev-list --no-merges --pretty M^1..M | git shortlog\n\nThe diffstat is \"what damage was inflicted on the branch you\nhave been following with this merge\", so the diff between the\ntrees before and after the merge is what you want.  And the\nrev-list piped to shortlog is to show \"what commits were _not_\npresent on this branch before the merge, but are present after\nthe merge\" (it could be spelled M^1..M^2 but the above would\nhandle octopus as well).\n"},{"id":"19925","messageId":"Pine.LNX.4.64.0605141122380.3866@g5.osdl.org","threadId":"4136","inReplyTo":"4fb292fa0605141021r20cefaa0he592b9c713ede333@mail.gmail.com","subject":"Re: Howto get the merge-base ?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-05-14T18:40:40Z","receivedAt":"2006-05-14T18:40:40Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 14 May 2006, Bertrand Jacquin wrote:\n> \n> I'm trying to know which commit it the parent of a merge.\n> For exemple if I do that :\n> \n>   o Merge\n>  / \\\n> /   \\\n> |   |\n> |   o Commit D\n> |   |\n> |   o Commit C\n> |   |\n> o   | Commit B\n> \\  /\n>  \\/\n>  o Commit A\n>  |\n>  o Init\n> \n> How could I know that ``Commit A'' is the merge-base of ``Merge'' ?\n\nWell, Junio already answered, but I'd like to comment a bit further.\n\nThere may not be \"one\" merge-base. There can be several:\n\n\t\tMerge\n\t\t  |\n\t\t  A\n\t\t / \\\n\t\tB   C\n\t\t|\\ /|\n\t\t| X |\n\t\t|/ \\|\n\t\tD   E\n\t\t \\ /\n\t\t  F\n\t\t  |\n\nHere the merge (A) has two equally good merge bases: D and E.\n\nIf you want all of these merge-bases, you need to add the \"--all\" flag to \ngit-merge-base.\n\nOn the git archive, try this trivia shell pipeline:\n\n\tgit-rev-list --parents HEAD |\n\t\tsed -n '/^[0-9a-f]* [0-9a-f]* [0-9a-f]*$/ p' |\n\t\twhile read a b c\n\t\tdo\n\t\t\techo $a: $(git merge-base --all $b $c)\n\t\tdone | less -S\n\nand you'll be able to easily pick up examples of where there are real \nmultiple merge bases. For example, commit 4da8cbc2.. has that.\n\nIf you want to examine _why_ it has multiple merge-bases, do:\n\n\tgitk 4da8cbc2 --not 5910e997 52b70d56\n\n(where the two \"not\" commits are the merge bases for it) which shows that \nmerge and the criss-crossing nature of the history leading up to it.\n\nNOTE! Most of the time, multiple merge bases do not really matter all that \nmuch, and you'd get the same merge regardless of which one you would \nchoose as the base. Still, they _can_ matter.\n\n\t\t\tLinus\n"}]}