* git rev-list ordering
@ 2008-11-16 0:44 Ian Hilt
2008-11-16 1:27 ` Sverre Rabbelier
0 siblings, 1 reply; 8+ messages in thread
From: Ian Hilt @ 2008-11-16 0:44 UTC (permalink / raw)
To: Git Mailing List
Why is it that this command,
git rev-list --reverse --max-count=1 <branch>
results in the same SHA1 as,
git rev-list --max-count=1 <branch>
So far, the documentation and the mailing list archives haven't helped.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: git rev-list ordering 2008-11-16 0:44 git rev-list ordering Ian Hilt @ 2008-11-16 1:27 ` Sverre Rabbelier 2008-11-16 1:44 ` Ian Hilt 0 siblings, 1 reply; 8+ messages in thread From: Sverre Rabbelier @ 2008-11-16 1:27 UTC (permalink / raw) To: Ian Hilt; +Cc: Git Mailing List On Sun, Nov 16, 2008 at 01:44, Ian Hilt <ian.hilt@gmx.com> wrote: > Why is it that this command, > > git rev-list --reverse --max-count=1 <branch> > > results in the same SHA1 as, > > git rev-list --max-count=1 <branch> > > So far, the documentation and the mailing list archives haven't helped. The --reverse is applied after the --max-count, so you are seeing the reverse of one commit ;). For comparison, have a look at: $ git rev-list --reverse --max-count=2 -- Cheers, Sverre Rabbelier ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: git rev-list ordering 2008-11-16 1:27 ` Sverre Rabbelier @ 2008-11-16 1:44 ` Ian Hilt 2008-11-16 21:16 ` Johannes Schindelin 0 siblings, 1 reply; 8+ messages in thread From: Ian Hilt @ 2008-11-16 1:44 UTC (permalink / raw) To: sverre; +Cc: Git Mailing List On Sat, 15 Nov 2008, Sverre Rabbelier wrote: > The --reverse is applied after the --max-count, so you are seeing the > reverse of one commit ;). For comparison, have a look at: > > $ git rev-list --reverse --max-count=2 Ah, I see. So if you didn't want the sorting to take a long time for many commits, you would limit the output to n commits, then sort the output. Is this the logic behind this design? ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: git rev-list ordering 2008-11-16 1:44 ` Ian Hilt @ 2008-11-16 21:16 ` Johannes Schindelin 2008-11-17 1:21 ` Ian Hilt 2008-11-18 20:28 ` Pete Harlan 0 siblings, 2 replies; 8+ messages in thread From: Johannes Schindelin @ 2008-11-16 21:16 UTC (permalink / raw) To: Ian Hilt; +Cc: sverre, Git Mailing List Hi, On Sat, 15 Nov 2008, Ian Hilt wrote: > On Sat, 15 Nov 2008, Sverre Rabbelier wrote: > > The --reverse is applied after the --max-count, so you are seeing the > > reverse of one commit ;). For comparison, have a look at: > > > > $ git rev-list --reverse --max-count=2 > > Ah, I see. So if you didn't want the sorting to take a long time for > many commits, you would limit the output to n commits, then sort the > output. Is this the logic behind this design? Yes. It is by design, since the guy who wrote the initial --reverse support cannot think of an interesting situation where you need to list the oldest n commits. Ciao, Dscho ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: git rev-list ordering 2008-11-16 21:16 ` Johannes Schindelin @ 2008-11-17 1:21 ` Ian Hilt 2008-11-17 1:35 ` Johannes Schindelin 2008-11-18 20:28 ` Pete Harlan 1 sibling, 1 reply; 8+ messages in thread From: Ian Hilt @ 2008-11-17 1:21 UTC (permalink / raw) To: Johannes Schindelin; +Cc: sverre, Git Mailing List On Sun, 16 Nov 2008, Johannes Schindelin wrote: > Hi, > > On Sat, 15 Nov 2008, Ian Hilt wrote: > > > On Sat, 15 Nov 2008, Sverre Rabbelier wrote: > > > The --reverse is applied after the --max-count, so you are seeing the > > > reverse of one commit ;). For comparison, have a look at: > > > > > > $ git rev-list --reverse --max-count=2 > > > > Ah, I see. So if you didn't want the sorting to take a long time for > > many commits, you would limit the output to n commits, then sort the > > output. Is this the logic behind this design? > > Yes. It is by design, since the guy who wrote the initial --reverse > support cannot think of an interesting situation where you need to list > the oldest n commits. I see. Well, the situation in which I found this to be needed was while trying to figure out how to find the next commit on branch X while on a detached head from that branch without counting how many commits back I was. In other words, $ git checkout X~4 $ # now I want X~3 without using a number or carets $ git checkout $(git rev-list --reverse ..X | head -1) -- or -- $ git checkout $(git rev-list ..X | tail -1) So maybe there's a better way to do this. I don't know. If the commits were reversed _then_ limited I wouldn't need to use the pipe to head/tail. Not that that is a problem, it just seemed like it should work with reverse and max-count. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Re: git rev-list ordering 2008-11-17 1:21 ` Ian Hilt @ 2008-11-17 1:35 ` Johannes Schindelin 0 siblings, 0 replies; 8+ messages in thread From: Johannes Schindelin @ 2008-11-17 1:35 UTC (permalink / raw) To: Ian Hilt; +Cc: sverre, Git Mailing List Hi, On Sun, 16 Nov 2008, Ian Hilt wrote: > On Sun, 16 Nov 2008, Johannes Schindelin wrote: > > > On Sat, 15 Nov 2008, Ian Hilt wrote: > > > > > On Sat, 15 Nov 2008, Sverre Rabbelier wrote: > > > > The --reverse is applied after the --max-count, so you are seeing > > > > the reverse of one commit ;). For comparison, have a look at: > > > > > > > > $ git rev-list --reverse --max-count=2 > > > > > > Ah, I see. So if you didn't want the sorting to take a long time > > > for many commits, you would limit the output to n commits, then sort > > > the output. Is this the logic behind this design? > > > > Yes. It is by design, since the guy who wrote the initial --reverse > > support cannot think of an interesting situation where you need to > > list the oldest n commits. > > I see. Well, the situation in which I found this to be needed was while > trying to figure out how to find the next commit on branch X while on a > detached head from that branch without counting how many commits back I > was. In other words, > > $ git checkout X~4 > $ # now I want X~3 without using a number or carets > $ git checkout $(git rev-list --reverse ..X | head -1) > -- or -- > $ git checkout $(git rev-list ..X | tail -1) This could break down horribly when there was branching going on. However, in case you are certain there is only one child of X~4, I'd suggest doing this: $ git checkout $(git rev-list --parents --all ^HEAD | sed -n "s/ .*$(git rev-parse HEAD).*$//p") IOW I would list all revisions with parents, and filter out all which do not have the current one as parent. Hth, Dscho ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: git rev-list ordering 2008-11-16 21:16 ` Johannes Schindelin 2008-11-17 1:21 ` Ian Hilt @ 2008-11-18 20:28 ` Pete Harlan 2008-11-19 8:26 ` Björn Steinbrink 1 sibling, 1 reply; 8+ messages in thread From: Pete Harlan @ 2008-11-18 20:28 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Ian Hilt, sverre, Git Mailing List Johannes Schindelin wrote: > Hi, > > On Sat, 15 Nov 2008, Ian Hilt wrote: > >> On Sat, 15 Nov 2008, Sverre Rabbelier wrote: >>> The --reverse is applied after the --max-count, so you are seeing the >>> reverse of one commit ;). For comparison, have a look at: >>> >>> $ git rev-list --reverse --max-count=2 >> Ah, I see. So if you didn't want the sorting to take a long time for >> many commits, you would limit the output to n commits, then sort the >> output. Is this the logic behind this design? > > Yes. It is by design, since the guy who wrote the initial --reverse > support cannot think of an interesting situation where you need to list > the oldest n commits. I have a script that runs periodically where I need to know the email address of who added $file to the system, for a handful of $files, because I'm moving them somewhere else and want to let them know. The most recent commits aren't interesting, it's the first commit that matters. I use: git rev-list --reverse --pretty=format:%ae HEAD -- $file and the second line has the information I need. Perhaps there's a more straightforward way to answer the question "who first put this file here". (One can imagine that may be no "first", because $file merged from different paths, but in mine as in many real-world cases, it (a) won't happen and (b) whatever happens will be fine if it does.) I don't need this to work differently than it does, but perhaps it constitutes an "interesting situation where you need to list the oldest n commits"? Thank you for your numerous contributions, --Pete ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: git rev-list ordering 2008-11-18 20:28 ` Pete Harlan @ 2008-11-19 8:26 ` Björn Steinbrink 0 siblings, 0 replies; 8+ messages in thread From: Björn Steinbrink @ 2008-11-19 8:26 UTC (permalink / raw) To: Pete Harlan; +Cc: Johannes Schindelin, Ian Hilt, sverre, Git Mailing List On 2008.11.18 12:28:27 -0800, Pete Harlan wrote: > I have a script that runs periodically where I need to know the email > address of who added $file to the system, for a handful of $files, > because I'm moving them somewhere else and want to let them know. The > most recent commits aren't interesting, it's the first commit that matters. > > I use: > > git rev-list --reverse --pretty=format:%ae HEAD -- $file > > and the second line has the information I need. > > Perhaps there's a more straightforward way to answer the question "who > first put this file here". > > (One can imagine that may be no "first", because $file merged from > different paths, but in mine as in many real-world cases, it (a) won't > happen and (b) whatever happens will be fine if it does.) > > I don't need this to work differently than it does, but perhaps it > constitutes an "interesting situation where you need to list the oldest > n commits"? What you're asking for are commits that added the file, and you can tell git to find them, instead of using the --reverse work-around: git log --diff-filter=A --pretty=format:%ae HEAD -- $file If you're running that with a single file, you might want to add --follow and maybe add R to the diff-filter as well (to get the renaming commits). Björn ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-11-19 8:28 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-11-16 0:44 git rev-list ordering Ian Hilt 2008-11-16 1:27 ` Sverre Rabbelier 2008-11-16 1:44 ` Ian Hilt 2008-11-16 21:16 ` Johannes Schindelin 2008-11-17 1:21 ` Ian Hilt 2008-11-17 1:35 ` Johannes Schindelin 2008-11-18 20:28 ` Pete Harlan 2008-11-19 8:26 ` Björn Steinbrink
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox