{"thread":{"id":"40403","subject":"Specifying N revisions after the initial commit","startedAt":"2015-09-22T18:32:19Z","lastAt":"2015-09-22T20:42:26Z","messageCount":7,"participants":["Josh Boyer","Konstantin Khomoutov","Junio C Hamano","Theodore Ts'o"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"270503","messageId":"CA+5PVA40x8bxW63X+b77FDO8btRBaVOg=fq+ZyX=bdJ+uEm9gA@mail.gmail.com","threadId":"40403","inReplyTo":null,"subject":"Specifying N revisions after the initial commit","fromName":"Josh Boyer","fromEmail":"jwboyer@gmail.com","sentAt":"2015-09-22T18:32:19Z","receivedAt":"2015-09-22T18:32:19Z","isPatch":false,"sender":{"key":"jwboyer@gmail.com","avatar":null},"body":"Hi All,\n\nPlease CC me as I'm not subscribed.\n\nI was hoping someone could help me with the revision shorthand to get\nthe commit sha of a commit N commits after the initial commit.  Thus\nfar I've figured out that to get the initial commit in a repository,\nyou can use:\n\ngit rev-list --max-parents=0 HEAD\n\nbut I can't figure out how to get \"give me the commit sha1 of the\ncommit immediately after the initial commit\", or for some number N.  I\ncould always do something like:\n\ngit rev-list HEAD | tail -2\n\nto get both, but I was curious if there was a refspec shorthand for\nthis that could be used.  It seems that git's rev parsing is all built\non going backwards in order (and probably rightfully so).\n\nThanks in advance.\n\njosh\n"},{"id":"270506","messageId":"20150922214037.b6b48059f051fcd4060a5a85@domain007.com","threadId":"40403","inReplyTo":"CA+5PVA40x8bxW63X+b77FDO8btRBaVOg=fq+ZyX=bdJ+uEm9gA@mail.gmail.com","subject":"Re: Specifying N revisions after the initial commit","fromName":"Konstantin Khomoutov","fromEmail":"kostix+git@007spb.ru","sentAt":"2015-09-22T18:40:37Z","receivedAt":"2015-09-22T18:40:37Z","isPatch":false,"sender":{"key":"kostix+git@007spb.ru","avatar":null},"body":"On Tue, 22 Sep 2015 14:32:19 -0400\nJosh Boyer <jwboyer@gmail.com> wrote:\n\n> Please CC me as I'm not subscribed.\n> \n> I was hoping someone could help me with the revision shorthand to get\n> the commit sha of a commit N commits after the initial commit.\n\nWhat happens if right after the initial commit, there have been five\nbranches created -- with no common commits except for the initial one?\n\nThat's the core limitation of the data model Git uses (and arguably any\nother DVCS system): all commits form a directed acyclic graph.\nThe \"directed\" in that construct means that child commits contain a\nlink to their parent commit (or commits) but not vice-versa.\n\nHence, given any particular commit, you're able to trace all of its\nancestry, but the reverse is not possible.\n"},{"id":"270511","messageId":"CA+5PVA6YWJizRjseeJ4EpRya0Mpyrv3DoNsB3=Gi=dOiAoDfHg@mail.gmail.com","threadId":"40403","inReplyTo":"20150922214037.b6b48059f051fcd4060a5a85@domain007.com","subject":"Re: Specifying N revisions after the initial commit","fromName":"Josh Boyer","fromEmail":"jwboyer@gmail.com","sentAt":"2015-09-22T19:10:42Z","receivedAt":"2015-09-22T19:10:42Z","isPatch":false,"sender":{"key":"jwboyer@gmail.com","avatar":null},"body":"On Tue, Sep 22, 2015 at 2:40 PM, Konstantin Khomoutov\n<kostix+git@007spb.ru> wrote:\n> On Tue, 22 Sep 2015 14:32:19 -0400\n> Josh Boyer <jwboyer@gmail.com> wrote:\n>\n>> Please CC me as I'm not subscribed.\n>>\n>> I was hoping someone could help me with the revision shorthand to get\n>> the commit sha of a commit N commits after the initial commit.\n>\n> What happens if right after the initial commit, there have been five\n> branches created -- with no common commits except for the initial one?\n>\n> That's the core limitation of the data model Git uses (and arguably any\n> other DVCS system): all commits form a directed acyclic graph.\n> The \"directed\" in that construct means that child commits contain a\n> link to their parent commit (or commits) but not vice-versa.\n\nHm.  It has been so long since I've looked at the underlying model and\ngit has proven to be so flexible on such a variety of things that I\nguess I forgot it was constructed through a DAG.  The --reverse\nparameter to git-log and git-rev-parse had left me hopeful.\n\n> Hence, given any particular commit, you're able to trace all of its\n> ancestry, but the reverse is not possible.\n\nThat makes sense.  I suppose I will have to resort to parsing output\nof git-rev-list or something.  Thanks for the reminder.\n\njosh\n"},{"id":"270519","messageId":"xmqqpp1a2pql.fsf@gitster.mtv.corp.google.com","threadId":"40403","inReplyTo":"CA+5PVA6YWJizRjseeJ4EpRya0Mpyrv3DoNsB3=Gi=dOiAoDfHg@mail.gmail.com","subject":"Re: Specifying N revisions after the initial commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-09-22T19:55:30Z","receivedAt":"2015-09-22T19:55:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Josh Boyer <jwboyer@gmail.com> writes:\n\n> On Tue, Sep 22, 2015 at 2:40 PM, Konstantin Khomoutov\n> ...\n>> Hence, given any particular commit, you're able to trace all of its\n>> ancestry, but the reverse is not possible.\n>\n> That makes sense.  I suppose I will have to resort to parsing output\n> of git-rev-list or something.  Thanks for the reminder.\n\nI think Konstantin explained why it fundamentally does not make\nsense to ask \"which one is the Nth one after the root\".  I am not\nsure how running rev-list and count its output would help, unless\nyou are now solving a different problem (perhaps \"find all the ones\nthat are Nth after some root\", which does have an answer).\n"},{"id":"270522","messageId":"CA+5PVA6zUXGs2R-MOoj5sBxwUqM7HP=tx-0WZJzPf71MsjH9MA@mail.gmail.com","threadId":"40403","inReplyTo":"xmqqpp1a2pql.fsf@gitster.mtv.corp.google.com","subject":"Re: Specifying N revisions after the initial commit","fromName":"Josh Boyer","fromEmail":"jwboyer@gmail.com","sentAt":"2015-09-22T20:11:23Z","receivedAt":"2015-09-22T20:11:23Z","isPatch":false,"sender":{"key":"jwboyer@gmail.com","avatar":null},"body":"On Tue, Sep 22, 2015 at 3:55 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Josh Boyer <jwboyer@gmail.com> writes:\n>\n>> On Tue, Sep 22, 2015 at 2:40 PM, Konstantin Khomoutov\n>> ...\n>>> Hence, given any particular commit, you're able to trace all of its\n>>> ancestry, but the reverse is not possible.\n>>\n>> That makes sense.  I suppose I will have to resort to parsing output\n>> of git-rev-list or something.  Thanks for the reminder.\n>\n> I think Konstantin explained why it fundamentally does not make\n> sense to ask \"which one is the Nth one after the root\".  I am not\n> sure how running rev-list and count its output would help, unless\n> you are now solving a different problem (perhaps \"find all the ones\n> that are Nth after some root\", which does have an answer).\n\nOh, context would help, yes.  In the case of the tree I'm parsing, I\nknow for a fact that the commit history is entirely linear and will\n(should) always remain so.  E.g.\n\nA - B - C - D - E - F ... {N}\n\nSo yes, finding e.g. the second commit after the root is complicated\nfor something resembling anything like a typical git repo, but this\nisn't like that.  In other words, I can cheat.  Or at least I'm pretty\nsure I can cheat :).\n\njosh\n"},{"id":"270526","messageId":"20150922204000.GC3318@thunk.org","threadId":"40403","inReplyTo":"CA+5PVA6zUXGs2R-MOoj5sBxwUqM7HP=tx-0WZJzPf71MsjH9MA@mail.gmail.com","subject":"Re: Specifying N revisions after the initial commit","fromName":"Theodore Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2015-09-22T20:40:00Z","receivedAt":"2015-09-22T20:40:00Z","isPatch":false,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"On Tue, Sep 22, 2015 at 04:11:23PM -0400, Josh Boyer wrote:\n> Oh, context would help, yes.  In the case of the tree I'm parsing, I\n> know for a fact that the commit history is entirely linear and will\n> (should) always remain so.  E.g.\n> \n> A - B - C - D - E - F ... {N}\n> \n> So yes, finding e.g. the second commit after the root is complicated\n> for something resembling anything like a typical git repo, but this\n> isn't like that.  In other words, I can cheat.  Or at least I'm pretty\n> sure I can cheat :).\n\nI'd suggest making your script makes sure \"git rev-list --merges A..N\"\ndoesn't output any commits, so you know for sure that the commit\nhistory is linear.  That way you'll be certain that you can cheat.  :-)\n\n\t   \t    \t     \t    - Ted\n"},{"id":"270527","messageId":"xmqq1tdq2nkd.fsf@gitster.mtv.corp.google.com","threadId":"40403","inReplyTo":"20150922204000.GC3318@thunk.org","subject":"Re: Specifying N revisions after the initial commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-09-22T20:42:26Z","receivedAt":"2015-09-22T20:42:26Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Theodore Ts'o <tytso@mit.edu> writes:\n\n> On Tue, Sep 22, 2015 at 04:11:23PM -0400, Josh Boyer wrote:\n>> Oh, context would help, yes.  In the case of the tree I'm parsing, I\n>> know for a fact that the commit history is entirely linear and will\n>> (should) always remain so.  E.g.\n>> \n>> A - B - C - D - E - F ... {N}\n>> \n>> So yes, finding e.g. the second commit after the root is complicated\n>> for something resembling anything like a typical git repo, but this\n>> isn't like that.  In other words, I can cheat.  Or at least I'm pretty\n>> sure I can cheat :).\n>\n> I'd suggest making your script makes sure \"git rev-list --merges A..N\"\n> doesn't output any commits, so you know for sure that the commit\n> history is linear.  That way you'll be certain that you can cheat.  :-)\n\nThere are histories with multiple roots without any merges, in which\ncase you cannot ;-)\n"}]}