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

Re: add 'ls-remote' option to limit output records

From
Jeff King <peff@peff.net>
Date
May 1, 2019, 18:23 UTC
Message-ID
<20190501182323.GD4109@sigill.intra.peff.net>
In-Reply-To
<CAGyf7-G+FEDVe=WiVVNJr1ALn-ryA4862qbjdDCNXM+LhpjORQ@mail.gmail.com>
On Fri, Apr 26, 2019 at 12:32:51PM -0700, Bryan Turner wrote:
Show 11 quoted lines
> >         $ 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
Previous: Bryan Turner
Message 3 of 3 in “add 'ls-remote' option to limit output records”
  1. David CarsonApr 26, 2019
  2. Bryan TurnerApr 26, 2019
  3. Jeff KingMay 1, 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.