{"thread":{"id":"16346","subject":"git rev-list ordering","startedAt":"2008-11-16T00:44:03Z","lastAt":"2008-11-19T08:26:38Z","messageCount":8,"participants":["Ian Hilt","Sverre Rabbelier","Johannes Schindelin","Pete Harlan","Björn Steinbrink"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"95917","messageId":"alpine.LFD.2.00.0811151922310.2935@sys-0.hiltweb.site","threadId":"16346","inReplyTo":null,"subject":"git rev-list ordering","fromName":"Ian Hilt","fromEmail":"ian.hilt@gmx.com","sentAt":"2008-11-16T00:44:03Z","receivedAt":"2008-11-16T00:44:03Z","isPatch":false,"sender":{"key":"ian.hilt@gmx.com","avatar":null},"body":"Why is it that this command,\n\n    git rev-list --reverse --max-count=1 <branch>\n\nresults in the same SHA1 as,\n\n    git rev-list --max-count=1 <branch>\n\nSo far, the documentation and the mailing list archives haven't helped.\n"},{"id":"95920","messageId":"bd6139dc0811151727k605a3575hf409fed32a3a4baf@mail.gmail.com","threadId":"16346","inReplyTo":"alpine.LFD.2.00.0811151922310.2935@sys-0.hiltweb.site","subject":"Re: git rev-list ordering","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-11-16T01:27:51Z","receivedAt":"2008-11-16T01:27:51Z","isPatch":false,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"On Sun, Nov 16, 2008 at 01:44, Ian Hilt <ian.hilt@gmx.com> wrote:\n> Why is it that this command,\n>\n>    git rev-list --reverse --max-count=1 <branch>\n>\n> results in the same SHA1 as,\n>\n>    git rev-list --max-count=1 <branch>\n>\n> So far, the documentation and the mailing list archives haven't helped.\n\nThe --reverse is applied after the --max-count, so you are seeing the\nreverse of one commit ;). For comparison, have a look at:\n\n$ git rev-list --reverse --max-count=2\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"95922","messageId":"alpine.LFD.2.00.0811152040570.2935@sys-0.hiltweb.site","threadId":"16346","inReplyTo":"bd6139dc0811151727k605a3575hf409fed32a3a4baf@mail.gmail.com","subject":"Re: git rev-list ordering","fromName":"Ian Hilt","fromEmail":"ian.hilt@gmx.com","sentAt":"2008-11-16T01:44:18Z","receivedAt":"2008-11-16T01:44:18Z","isPatch":false,"sender":{"key":"ian.hilt@gmx.com","avatar":null},"body":"On Sat, 15 Nov 2008, Sverre Rabbelier wrote:\n> The --reverse is applied after the --max-count, so you are seeing the\n> reverse of one commit ;). For comparison, have a look at:\n> \n> $ git rev-list --reverse --max-count=2\n\nAh, I see.  So if you didn't want the sorting to take a long time for\nmany commits, you would limit the output to n commits, then sort the\noutput.  Is this the logic behind this design?\n"},{"id":"95971","messageId":"alpine.DEB.1.00.0811162215370.30769@pacific.mpi-cbg.de","threadId":"16346","inReplyTo":"alpine.LFD.2.00.0811152040570.2935@sys-0.hiltweb.site","subject":"Re: git rev-list ordering","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-11-16T21:16:34Z","receivedAt":"2008-11-16T21:16:34Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 15 Nov 2008, Ian Hilt wrote:\n\n> On Sat, 15 Nov 2008, Sverre Rabbelier wrote:\n> > The --reverse is applied after the --max-count, so you are seeing the \n> > reverse of one commit ;). For comparison, have a look at:\n> > \n> > $ git rev-list --reverse --max-count=2\n> \n> Ah, I see.  So if you didn't want the sorting to take a long time for \n> many commits, you would limit the output to n commits, then sort the \n> output.  Is this the logic behind this design?\n\nYes.  It is by design, since the guy who wrote the initial --reverse \nsupport cannot think of an interesting situation where you need to list \nthe oldest n commits.\n\nCiao,\nDscho\n"},{"id":"96001","messageId":"alpine.LFD.2.00.0811162001550.28544@sys-0.hiltweb.site","threadId":"16346","inReplyTo":"alpine.DEB.1.00.0811162215370.30769@pacific.mpi-cbg.de","subject":"Re: git rev-list ordering","fromName":"Ian Hilt","fromEmail":"ian.hilt@gmx.com","sentAt":"2008-11-17T01:21:40Z","receivedAt":"2008-11-17T01:21:40Z","isPatch":false,"sender":{"key":"ian.hilt@gmx.com","avatar":null},"body":"On Sun, 16 Nov 2008, Johannes Schindelin wrote:\n> Hi,\n> \n> On Sat, 15 Nov 2008, Ian Hilt wrote:\n> \n> > On Sat, 15 Nov 2008, Sverre Rabbelier wrote:\n> > > The --reverse is applied after the --max-count, so you are seeing the \n> > > reverse of one commit ;). For comparison, have a look at:\n> > > \n> > > $ git rev-list --reverse --max-count=2\n> > \n> > Ah, I see.  So if you didn't want the sorting to take a long time for \n> > many commits, you would limit the output to n commits, then sort the \n> > output.  Is this the logic behind this design?\n> \n> Yes.  It is by design, since the guy who wrote the initial --reverse \n> support cannot think of an interesting situation where you need to list \n> the oldest n commits.\n\nI see.  Well, the situation in which I found this to be needed was while \ntrying to figure out how to find the next commit on branch X while on a \ndetached head from that branch without counting how many commits back I \nwas.  In other words,\n\n$ git checkout X~4\n$ # now I want X~3 without using a number or carets\n$ git checkout $(git rev-list --reverse ..X | head -1)\n -- or --\n$ git checkout $(git rev-list ..X | tail -1)\n\nSo maybe there's a better way to do this.  I don't know.  If the commits\nwere reversed _then_ limited I wouldn't need to use the pipe to\nhead/tail.  Not that that is a problem, it just seemed like it should\nwork with reverse and max-count.\n"},{"id":"96003","messageId":"alpine.DEB.1.00.0811170231430.30769@pacific.mpi-cbg.de","threadId":"16346","inReplyTo":"alpine.LFD.2.00.0811162001550.28544@sys-0.hiltweb.site","subject":"Re: Re: git rev-list ordering","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-11-17T01:35:26Z","receivedAt":"2008-11-17T01:35:26Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 16 Nov 2008, Ian Hilt wrote:\n\n> On Sun, 16 Nov 2008, Johannes Schindelin wrote:\n> \n> > On Sat, 15 Nov 2008, Ian Hilt wrote:\n> > \n> > > On Sat, 15 Nov 2008, Sverre Rabbelier wrote:\n> > > > The --reverse is applied after the --max-count, so you are seeing \n> > > > the reverse of one commit ;). For comparison, have a look at:\n> > > > \n> > > > $ git rev-list --reverse --max-count=2\n> > > \n> > > Ah, I see.  So if you didn't want the sorting to take a long time \n> > > for many commits, you would limit the output to n commits, then sort \n> > > the output.  Is this the logic behind this design?\n> > \n> > Yes.  It is by design, since the guy who wrote the initial --reverse \n> > support cannot think of an interesting situation where you need to \n> > list the oldest n commits.\n> \n> I see.  Well, the situation in which I found this to be needed was while \n> trying to figure out how to find the next commit on branch X while on a \n> detached head from that branch without counting how many commits back I \n> was.  In other words,\n> \n> $ git checkout X~4\n> $ # now I want X~3 without using a number or carets\n> $ git checkout $(git rev-list --reverse ..X | head -1)\n>  -- or --\n> $ git checkout $(git rev-list ..X | tail -1)\n\nThis could break down horribly when there was branching going on.  \nHowever, in case you are certain there is only one child of X~4, I'd \nsuggest doing this:\n\n$ git checkout $(git rev-list --parents --all ^HEAD |\n\tsed -n \"s/ .*$(git rev-parse HEAD).*$//p\")\n\nIOW I would list all revisions with parents, and filter out all which do \nnot have the current one as parent.\n\nHth,\nDscho\n"},{"id":"96096","messageId":"4923256B.3000807@pcharlan.com","threadId":"16346","inReplyTo":"alpine.DEB.1.00.0811162215370.30769@pacific.mpi-cbg.de","subject":"Re: git rev-list ordering","fromName":"Pete Harlan","fromEmail":"pgit@pcharlan.com","sentAt":"2008-11-18T20:28:27Z","receivedAt":"2008-11-18T20:28:27Z","isPatch":false,"sender":{"key":"pgit@pcharlan.com","avatar":null},"body":"Johannes Schindelin wrote:\n> Hi,\n> \n> On Sat, 15 Nov 2008, Ian Hilt wrote:\n> \n>> On Sat, 15 Nov 2008, Sverre Rabbelier wrote:\n>>> The --reverse is applied after the --max-count, so you are seeing the \n>>> reverse of one commit ;). For comparison, have a look at:\n>>>\n>>> $ git rev-list --reverse --max-count=2\n>> Ah, I see.  So if you didn't want the sorting to take a long time for \n>> many commits, you would limit the output to n commits, then sort the \n>> output.  Is this the logic behind this design?\n> \n> Yes.  It is by design, since the guy who wrote the initial --reverse \n> support cannot think of an interesting situation where you need to list \n> the oldest n commits.\n\nI have a script that runs periodically where I need to know the email\naddress of who added $file to the system, for a handful of $files,\nbecause I'm moving them somewhere else and want to let them know.  The\nmost recent commits aren't interesting, it's the first commit that matters.\n\nI use:\n\n  git rev-list --reverse --pretty=format:%ae HEAD -- $file\n\nand the second line has the information I need.\n\nPerhaps there's a more straightforward way to answer the question \"who\nfirst put this file here\".\n\n(One can imagine that may be no \"first\", because $file merged from\ndifferent paths, but in mine as in many real-world cases, it (a) won't\nhappen and (b) whatever happens will be fine if it does.)\n\nI don't need this to work differently than it does, but perhaps it\nconstitutes an \"interesting situation where you need to list the oldest\nn commits\"?\n\nThank you for your numerous contributions,\n\n--Pete\n"},{"id":"96127","messageId":"20081119082638.GA3538@atjola.homenet","threadId":"16346","inReplyTo":"4923256B.3000807@pcharlan.com","subject":"Re: git rev-list ordering","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-11-19T08:26:38Z","receivedAt":"2008-11-19T08:26:38Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.11.18 12:28:27 -0800, Pete Harlan wrote:\n> I have a script that runs periodically where I need to know the email\n> address of who added $file to the system, for a handful of $files,\n> because I'm moving them somewhere else and want to let them know.  The\n> most recent commits aren't interesting, it's the first commit that matters.\n> \n> I use:\n> \n>   git rev-list --reverse --pretty=format:%ae HEAD -- $file\n> \n> and the second line has the information I need.\n> \n> Perhaps there's a more straightforward way to answer the question \"who\n> first put this file here\".\n> \n> (One can imagine that may be no \"first\", because $file merged from\n> different paths, but in mine as in many real-world cases, it (a) won't\n> happen and (b) whatever happens will be fine if it does.)\n> \n> I don't need this to work differently than it does, but perhaps it\n> constitutes an \"interesting situation where you need to list the oldest\n> n commits\"?\n\nWhat you're asking for are commits that added the file, and you can tell\ngit to find them, instead of using the --reverse work-around:\n\ngit log --diff-filter=A --pretty=format:%ae HEAD -- $file\n\nIf you're running that with a single file, you might want to add\n--follow and maybe add R to the diff-filter as well (to get the renaming\ncommits).\n\nBjörn\n"}]}