git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Make "git log --count" work like "git rev-list"

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jan 9, 2019, 17:44 UTC
Message-ID
<CAHk-=wjip45uqONG=Qzevd0HoT47t7NatSpr+N3ifMZehr2M0Q@mail.gmail.com>
In-Reply-To
<CAGZ79kaOcoVSRgTR+k9ENoDz6FHh27MzpZ9D-MeFArN2vgBK0w@mail.gmail.com>
On Wed, Jan 9, 2019 at 9:21 AM Stefan Beller <sbeller@google.com> wrote:
Show 8 quoted lines
>
> Sounds reasonable to me to have such functionality,
> as I tend to use
>   git log --oneline origin/master..origin/next --no-merges |wc -l
> for such queries, which I always assume to be doing useless
> work as I'd be interested in *only* the count, and not the
> intermediate oneline output, but that is the best output
> that wc works on.

Right. I've been known to do that too, but because I grew up with "git rev-list", I know about --count and tend to use it.

In fact, I've occasionally used it with "git log" already (before my patch), and it would silently accept the parameter (because it's parsed by the generic revision parsing), it just wouldn't work.

> So maybe the --count option would want to suppress
> other output if given (or we'd want to have another option
> for no output)?

It already does so in my patch, exactly because it uses the same logic as "git rev-list --count" does.

Which is to simply react to the "--count" thing early in log_tree_commit(), and do the counting and then say "I showed this" (without showing anything).

So you can do silly things like this:
    [torvalds@i7 linux]$ git log --count -10
    10
    [torvalds@i7 linux]$
and it just works. Nonsensical, but logical.
              Linus
Previous: Stefan BellerNext: Jeff King
Message 3 of 7 in “Make "git log --count" work like "git rev-list"”
  1. Linus TorvaldsJan 5, 2019
  2. Stefan BellerJan 9, 2019
  3. Linus TorvaldsJan 9, 2019
  4. Jeff KingJan 9, 2019
  5. Stefan BellerJan 9, 2019
  6. Junio C HamanoJan 10, 2019
  7. Jeff KingJan 11, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.