{"thread":{"id":"14185","subject":"Determining if two commits are on a separate branch","startedAt":"2008-06-27T14:55:51Z","lastAt":"2008-06-27T15:17:39Z","messageCount":3,"participants":["Adr3nal D0S","Michael J Gruber","Santi Béjar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"81408","messageId":"308083c30806270755t4316be67u1f468b51bf475d28@mail.gmail.com","threadId":"14185","inReplyTo":null,"subject":"Determining if two commits are on a separate branch","fromName":"Adr3nal D0S","fromEmail":"adr3nald0s@gmail.com","sentAt":"2008-06-27T14:55:51Z","receivedAt":"2008-06-27T14:55:51Z","isPatch":false,"sender":{"key":"adr3nald0s@gmail.com","avatar":null},"body":"We are making extensive use of submodules at work and we have created\na number of extra scripts to simplify our usage.  For example, there\nis git-rstatus, which recursively reports status of all submodules.\n\nI am working on another script to check whether or not a change to any\nsubmodules jump branches.  If we have commits like this:\n\nA--B--C\n   \\--D\n\nI don't care if a submodule moves from A to C or B to C, but I do care\nif a commit of the super-project would cause a jump from D to C or\nrevert from C to B, effectively dropping previously committed code on\nthe floor.\n\nSo, is there a \"correct\" or \"best\" way to determine if one commit's\nSHA follows directly from another's SHA in the commit history?\n"},{"id":"81409","messageId":"g4302r$ms9$1@ger.gmane.org","threadId":"14185","inReplyTo":"308083c30806270755t4316be67u1f468b51bf475d28@mail.gmail.com","subject":"Re: Determining if two commits are on a separate branch","fromName":"Michael J Gruber","fromEmail":"michaeljgruber+gmane@fastmail.fm","sentAt":"2008-06-27T15:13:29Z","receivedAt":"2008-06-27T15:13:29Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Adr3nal D0S venit, vidit, dixit 27.06.2008 16:55:\n> We are making extensive use of submodules at work and we have created\n> a number of extra scripts to simplify our usage.  For example, there\n> is git-rstatus, which recursively reports status of all submodules.\n> \n> I am working on another script to check whether or not a change to any\n> submodules jump branches.  If we have commits like this:\n> \n> A--B--C\n>    \\--D\n> \n> I don't care if a submodule moves from A to C or B to C, but I do care\n> if a commit of the super-project would cause a jump from D to C or\n> revert from C to B, effectively dropping previously committed code on\n> the floor.\n> \n> So, is there a \"correct\" or \"best\" way to determine if one commit's\n> SHA follows directly from another's SHA in the commit history?\n\n\"Directly\" as in \"is child of\", or as in \"connected by the DAG\"?\n\n\"git rev-list C..B\" lists all commits which are not in C but in B. If \nthis list is empty then B is \"contained\" in C. This is how you can test \nfor being connected by the DAG. For the graph above, all of the \nfollowing refspecs would return an empty list, indicating connectedness:\n\nC..B\nC..A\nB..A\nD..B\nD..A\n\nAre those the \"good ones\" in your case? Then you know how to test for \nthe bad guys ;)\n\nMichael\n"},{"id":"81410","messageId":"8aa486160806270817j1cab369eyc2d74996e9a3286f@mail.gmail.com","threadId":"14185","inReplyTo":"308083c30806270755t4316be67u1f468b51bf475d28@mail.gmail.com","subject":"Re: Determining if two commits are on a separate branch","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-06-27T15:17:39Z","receivedAt":"2008-06-27T15:17:39Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Fri, Jun 27, 2008 at 16:55, Adr3nal D0S <adr3nald0s@gmail.com> wrote:\n[...]\n\n> So, is there a \"correct\" or \"best\" way to determine if one commit's\n> SHA follows directly from another's SHA in the commit history?\n\nYou can compute the merge-base of these two commits and if the base is\none of them then it is a fast-forward.\n\nFor example, in git.git:\n\n$ git merge-base origin/next origin/master\nd54467b8c319571b5dc433b1f7e471c4b0f21caf\n\n$ git rev-parse origin/next origin/master\n3e7d305293ce93d00d5e0e6371311f7caa94f497\nd54467b8c319571b5dc433b1f7e471c4b0f21caf\n\nThe merge-base is origin/master so it is an ancestor of origin/next.\n\nHTH\n\nSanti\n"}]}