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

Re: [PATCH] ls-remote: create '--count' option

From
Johannes Sixt <j6t@kdbg.org>
Date
Sep 19, 2019, 18:40 UTC
Message-ID
<c839c38e-00ac-a1de-a246-8e92f16cfb4a@kdbg.org>
In-Reply-To
<21455bdb-431e-2842-0618-2f36a18bb60e@domanski.co>
Am 18.09.19 um 23:44 schrieb Kamil Domański:
Show 21 quoted lines
> On 9/18/19 8:28 AM, Johannes Sixt wrote:
>> Am 18.09.19 um 02:11 schrieb Kamil Domański:
>>>     DESCRIPTION
>>>   -----------
>>> @@ -21,6 +21,11 @@ commit IDs.
>>>     OPTIONS
>>>   -------
>>> +--count=<count>::
>>> +    By default the command shows all refs that match
>>> +    `<pattern>`.  This option makes it stop after showing
>>> +    that many refs.
>> Is the meaning of this option perhaps:
>>
>>      Stops after the specified count of refs have been listed.
>>      If `--sort=<key>` is specified as well, refs are counted
>>      after sorting; otherwise, it is unspecified which subset
>>      of is listed.
> 
> Similarly, I merely copied the description used by 'for-each-ref'. I
> like your version as well, since it clarifies the relation to sorting.
> Should the description for 'for-each-ref' be changed as well then?

I am neutral. If you do it, then it should not happen in the same patch as this change.

Show 5 quoted lines
> ... it appears that 'for-each-ref' defaults to sorting
> by 'refname' (through ref_default_sorting() ) if no alternative sorting
> is provided, while 'ls-remote' does no such defaulting. Do you figure it
> would be a good idea to add another patch which would introduce a
> similar default in 'ls-remote'?

I don't think so. I would think that in the case of ls-remote it is preferable to stream refs to the output as soon as they are received from the remote. If refs must be sorted, it would have to wait until the remote has sent all refs before it can do anything.

That said, Junio's question remains open: why is piping though head -n not good enough?

-- Hannes
Previous: Kamil Domański
Message 5 of 5 in “ls-remote: create '--count' option”
  1. ls-remote: create '--count' optionKamil Domański, Sep 18, 2019
  2. Johannes SixtSep 18, 2019
  3. Junio C HamanoSep 18, 2019
  4. Kamil DomańskiSep 18, 2019
  5. Johannes SixtSep 19, 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.