From: Taylor Blau <me@ttaylorr.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Taylor Blau <me@ttaylorr.com>,
git@vger.kernel.org, derrickstolee@github.com
Subject: Re: [PATCH 0/2] builtin/show-ref.c: support `--count` for limiting output
Date: Mon, 6 Jun 2022 18:57:09 -0400 [thread overview]
Message-ID: <Yp6GRccc5UElNrZb@nand.local> (raw)
In-Reply-To: <xmqqo7z54d7g.fsf@gitster.g>
On Mon, Jun 06, 2022 at 03:52:19PM -0700, Junio C Hamano wrote:
> Taylor Blau <me@ttaylorr.com> 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.
I don't disagree. But `--pipe-to-head-N=3` feels like too broad a
stroke. This series at least imitates `for-each-ref`'s `--count`
option, which makes it feel acceptable to me (if not a little silly).
> > 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
No, Ruby is perfectly capable of doing that. But it involves an extra
process (two, if `head` isn't a shell builtin) and the additional
overhead of creating a pipe and passing data through it instead of
writing directly to stdout.
That isn't a complete show-stopper in most cases, but in
ultra-latency-sensitive applications like GitHub is using show-ref for,
being able to shave an extra process or so off matters.
If you're strongly opposed to having `show-ref` match `for-each-ref`'s
`--count` option, I won't be too sad. But I'm not in a huge rush to
replace this series with `git --pipe-to-head-N=<n>` either, FWIW.
Thanks,
Taylor
next prev parent reply other threads:[~2022-06-06 22:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-06 21:56 [PATCH 0/2] builtin/show-ref.c: support `--count` for limiting output Taylor Blau
2022-06-06 21:56 ` [PATCH 1/2] builtin/show-ref.c: rename `found_match` to `matches_nr` Taylor Blau
2022-06-06 21:56 ` [PATCH 2/2] builtin/show-ref.c: limit output with `--count` Taylor Blau
2022-06-06 23:09 ` Junio C Hamano
2022-06-07 8:07 ` Ævar Arnfjörð Bjarmason
2022-06-07 21:13 ` Taylor Blau
2022-06-07 21:31 ` Ævar Arnfjörð Bjarmason
2022-06-08 16:10 ` Junio C Hamano
2022-06-06 22:52 ` [PATCH 0/2] builtin/show-ref.c: support `--count` for limiting output Junio C Hamano
2022-06-06 22:57 ` Taylor Blau [this message]
2022-06-06 23:00 ` Junio C Hamano
2022-06-07 19:41 ` Derrick Stolee
2022-06-07 8:18 ` Ævar Arnfjörð Bjarmason
2022-06-07 21:04 ` Taylor Blau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yp6GRccc5UElNrZb@nand.local \
--to=me@ttaylorr.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.