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

Re: [PATCH 2/2] for-each-ref: add --count-matches option

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 26, 2023, 16:14 UTC
Message-ID
<xmqqbkh25hfr.fsf@gitster.g>
In-Reply-To
<9121e027fb9f157878a9624ce6c834b69cd38472.1687792197.git.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 6 quoted lines
> Each of these approaches is wasteful as it requires sending the list of
> matching reference names across a pipe plus the cost of parsing that
> output.
>
> Instead, it would be helpful to have a Git command that counts the
> number of refs matching a list of patterns.

For for-each-ref (which can be reused by branch and tag for no cost), I am on the fence but slightly in favor (partly because the code has already been written). But I have to wonder where changes that come from the above reasoning need to end, though.

Do we count branches and tags because "git branch --list | wc -l" is too costly? Should we teach "git remote" the same trick? How about "git stash list"? "git show-index $pack_index"? "git ls-files"?

How do we decide where to draw the line? When a command invocation in a large repository can produce records exceeding a million?

Previous: Derrick Stolee via GitGitGadgetNext: Jeff King
Message 3 of 12 in “[RFC] for-each-ref: add --count-matches mode”
  1. 0/2 [RFC] for-each-ref: add --count-matches modeDerrick Stolee via GitGitGadget, Jun 26, 2023
  2. 2/2 for-each-ref: add --count-matches optionDerrick Stolee via GitGitGadget, Jun 26, 2023
  3. Junio C HamanoJun 26, 2023
  4. Jeff KingJun 27, 2023
  5. Phillip WoodJun 27, 2023
  6. Junio C HamanoJun 27, 2023
  7. Jeff KingJun 27, 2023
  8. Phillip WoodJun 28, 2023
  9. Junio C HamanoJun 28, 2023
  10. René ScharfeJul 11, 2023
  11. Derrick StoleeJul 10, 2023
  12. 1/2 for-each-ref: extract ref output loopDerrick Stolee via GitGitGadget, Jun 26, 2023

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.