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

[PATCH 0/2] builtin/show-ref.c: support `--count` for limiting output

From
Taylor Blau <me@ttaylorr.com>
Date
Jun 6, 2022, 21:56 UTC
Message-ID
<cover.1654552560.git.me@ttaylorr.com>

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).

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`).

The first patch is preparatory, and the second patch implements the new option. This series doesn't conflict with my recent [1], and can be applied independently.

Thanks in advance for your review!
[1]: https://lore.kernel.org/git/3fa6932641f18d78156bbf60b1571383f2cb5046.1654293264.git.me@ttaylorr.com/
Taylor Blau (2):
  builtin/show-ref.c: rename `found_match` to `matches_nr`
  builtin/show-ref.c: limit output with `--count`
 Documentation/git-show-ref.txt |  7 ++++++-
 builtin/show-ref.c             | 29 +++++++++++++++++++++++++----
 t/t1403-show-ref.sh            | 21 +++++++++++++++++++++
 3 files changed, 52 insertions(+), 5 deletions(-)
-- 
2.36.1.94.gb0d54bedca
Next: Taylor Blau
Message 1 of 14 in “builtin/show-ref.c: support `--count` for limiting output”
  1. 0/2 builtin/show-ref.c: support `--count` for limiting outputTaylor Blau, Jun 6, 2022
  2. 1/2 builtin/show-ref.c: rename `found_match` to `matches_nr`Taylor Blau, Jun 6, 2022
  3. 2/2 builtin/show-ref.c: limit output with `--count`Taylor Blau, Jun 6, 2022
  4. Junio C HamanoJun 6, 2022
  5. Ævar Arnfjörð BjarmasonJun 7, 2022
  6. Taylor BlauJun 7, 2022
  7. Ævar Arnfjörð BjarmasonJun 7, 2022
  8. Junio C HamanoJun 8, 2022
  9. Junio C HamanoJun 6, 2022
  10. Taylor BlauJun 6, 2022
  11. Junio C HamanoJun 6, 2022
  12. Derrick StoleeJun 7, 2022
  13. Ævar Arnfjörð BjarmasonJun 7, 2022
  14. Taylor BlauJun 7, 2022

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.