Subject: Re: [PATCH 0/2] builtin/show-ref.c: support `--count` for limiting output

From: Junio C Hamano <[email-masked]>
Date: Mon, 06 Jun 2022 15:52:19 -0700

Taylor Blau <[email-masked]> writes:

> This short patch series adds support for a new `--count` argument for limiting
> the output of `show-ref` (à-la the `for-each-ref` option by the same name).

It makes me wonder why we limit this to show-ref.

    $ git --pipe-to-head-N=3 any-command args...

IOW, having to add an option like this feels absurd.

> This is useful in contexts where a caller wants to avoid enumerating more
> references than necessary (e.g., they only care whether a tag exists, but not
> how many or what they are called) but doesn't have control of the output stream
> (e.g., they are in Ruby and can't pipe the output to `head -n 1`).

Are you saying that Ruby is incapable of run a command line like

   av[0] = "sh"
   av[1] = "-c"
   av[2] = "git show-ref blah | head -n 1"
   av[3] = NULL

?