threads / discuss / 13740

Why does "git log --reverse -1" print the HEAD commit?

Subject: Why does "git log --reverse -1" print the HEAD commit?

## tl;dr

3 messages between May 31, 2008 and May 31, 2008.

replies: 2people: 2as markdown or json

Teemu Likonen· May 31, 2008, 14:11 UTC · lore

It feels wrong that "git log -1" and "git log --reverse -1" both print the same commit: HEAD. Why is that?

Since "git log --reverse" starts from the bottom I'd have expected "-1" to print one commit from the bottom.

Miklos Vajna· May 31, 2008, 14:24 UTC · re: Teemu Likonen · lore

Re: Why does "git log --reverse -1" print the HEAD commit?

On Sat, May 31, 2008 at 05:11:02PM +0300, Teemu Likonen <tlikonen@iki.fi> wrote:
Show 5 quoted lines
> It feels wrong that "git log -1" and "git log --reverse -1" both print
> the same commit: HEAD. Why is that?
> 
> Since "git log --reverse" starts from the bottom I'd have expected "-1"
> to print one commit from the bottom.

-1 limits the commit list to one element and then it prints that range in reverse order, which is the same for a single commit.

Teemu Likonen· May 31, 2008, 14:33 UTC · re: Miklos Vajna · lore

Re: Why does "git log --reverse -1" print the HEAD commit?

Miklos Vajna wrote (2008-05-31 16:24 +0200):
Show 10 quoted lines
> On Sat, May 31, 2008 at 05:11:02PM +0300, Teemu Likonen
> <tlikonen@iki.fi> wrote:
> > It feels wrong that "git log -1" and "git log --reverse -1" both
> > print the same commit: HEAD. Why is that?
> > 
> > Since "git log --reverse" starts from the bottom I'd have expected
> > "-1" to print one commit from the bottom.
> 
> -1 limits the commit list to one element and then it prints that range
> in reverse order, which is the same for a single commit.

Oh yeah, that's the logic, thanks. I find it counter-intuitive but I'll survive.

← back to recent threads