git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* add 'ls-remote' option to limit output records
@ 2019-04-26 18:56 David Carson
  2019-04-26 19:32 ` Bryan Turner
  0 siblings, 1 reply; 3+ messages in thread
From: David Carson @ 2019-04-26 18:56 UTC (permalink / raw)
  To: git

Given that 'ls-remote' can be sorted, it would be useful to be able to ask for a subset of the total number of result records.

For example, if I want to retrieve only the tag with the highest version, I would do so by adding this new option (-n1 in my example):

	$ git ls-remote -n1 --tags --sort=v:refname origin "v*"

That would save from having to receive a large list of tags from the remote, only one of which I care about.

~David



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: add 'ls-remote' option to limit output records
  2019-04-26 18:56 add 'ls-remote' option to limit output records David Carson
@ 2019-04-26 19:32 ` Bryan Turner
  2019-05-01 18:23   ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Bryan Turner @ 2019-04-26 19:32 UTC (permalink / raw)
  To: David Carson; +Cc: git

On Fri, Apr 26, 2019 at 11:57 AM David Carson
<DCarson@extremenetworks.com> wrote:
>
> Given that 'ls-remote' can be sorted, it would be useful to be able to ask for a subset of the total number of result records.
>
> For example, if I want to retrieve only the tag with the highest version, I would do so by adding this new option (-n1 in my example):
>
>         $ git ls-remote -n1 --tags --sort=v:refname origin "v*"
>
> That would save from having to receive a large list of tags from the remote, only one of which I care about.

That sort of filtering would have to be applied client side, at least
partially, so it wouldn't necessarily save as much as you'd hope.

With the v0/v1 wire protocol, the server speaks first and sends the
entire ref advertisement, so the filtering would have to be 100%
client side.

With the v2 wire protocol, the client could provide a prefix (like
`refs/tags/`, or potentially `refs/tags/v`) to reduce what the server
included in the ref advertisement, but even the v2 protocol doesn't
have anything for telling the server "Version parse these names and
then return the first N". That means the parsing, sorting and trimming
for the advertised tags would still all have to happen locally. (I'm
sure someone can correct me if I've misstated what protocol v2 can do
for filtering, but I don't see any "ls-refs" options that look like
they enable anything other than prefix matching.)

Not trying to imply any judgments on the feature request itself; I'm
just noting that if it was added it may not be quite the win you were
hoping for. In fact, with the existing wire protocol versions (all of
them), I suspect this would end up with identical bandwidth usage to:

$ git ls-remote --tags --sort=v:refname origin "v*" | head -1

It would take modifications to the wire protocol itself for this to
happen server-side, not just the `ls-remote` command.

Bryan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: add 'ls-remote' option to limit output records
  2019-04-26 19:32 ` Bryan Turner
@ 2019-05-01 18:23   ` Jeff King
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff King @ 2019-05-01 18:23 UTC (permalink / raw)
  To: Bryan Turner; +Cc: David Carson, git

On Fri, Apr 26, 2019 at 12:32:51PM -0700, Bryan Turner wrote:

> >         $ git ls-remote -n1 --tags --sort=v:refname origin "v*"
> [...]
> With the v2 wire protocol, the client could provide a prefix (like
> `refs/tags/`, or potentially `refs/tags/v`) to reduce what the server
> included in the ref advertisement, but even the v2 protocol doesn't
> have anything for telling the server "Version parse these names and
> then return the first N". That means the parsing, sorting and trimming
> for the advertised tags would still all have to happen locally. (I'm
> sure someone can correct me if I've misstated what protocol v2 can do
> for filtering, but I don't see any "ls-refs" options that look like
> they enable anything other than prefix matching.)

No, that sounds right. The "--tags" in the original command should cause
v2 to ask only for refs/tags/. But because of the way ls-remote matching
works, "v*" is not a pure prefix match, and would find
"refs/tags/foo/v1.2.3". So we can't use protocol-level matching to ask
for "refs/tags/v*".

There are no provisions in the protocol for sorting, nor for limiting
the output.

I didn't check, but I suspect some hosting-platform APIs might be able
to answer this with a single query.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-01 18:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-26 18:56 add 'ls-remote' option to limit output records David Carson
2019-04-26 19:32 ` Bryan Turner
2019-05-01 18:23   ` Jeff King

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).