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

Re: [PATCH] grep: add --max-count command line option

From
Paul Eggert <eggert@cs.ucla.edu>
Date
May 16, 2022, 07:28 UTC
Message-ID
<e89577f8-8f52-bf09-15f3-c534bf1a6c64@cs.ucla.edu>
In-Reply-To
<xmqqilq658b3.fsf@gitster.g>
On 5/15/22 22:57, Junio C Hamano wrote:
> It indeed is curious why GNU grep chose to immediately exit with 1
> when "-m 0" was given,

As I vaguely recall, if "-m 1" stops before "-m 2" does, then the idea was that it's reasonable for "-m 0" to stop before "-m 1" does, and the logical place to stop is right at the start, before any matches are found (i.e., exit with status 1).

What would be more useful for 'grep -m 0' to do? (Sorry, I came into this conversation just now.) Perhaps GNU 'grep -m 0' should change, if there's something better for it to do.

Show 5 quoted lines
> What "git grep -m -1" should do?  IIRC, OPT_INTEGER is for signed
> integer but the new .max_count member, as well as the existing
> "count" that is compared with it, are of "unsigned" type.  Either
> erroring out or treating it as unlimited is probably fine, but
> whatever we do, we should document and have a test for it.

'grep -m -1' treats the count as being unlimited, but this isn't documented and (from the code) appears to be accidental. It'd make sense for it to be documented.

Previous: Junio C HamanoNext: Carlos L.
Message 4 of 8 in “grep: add --max-count command line option”
  1. grep: add --max-count command line optionCarlos L. via GitGitGadget, May 12, 2022
  2. Martin ÅgrenMay 14, 2022
  3. Junio C HamanoMay 16, 2022
  4. Paul EggertMay 16, 2022
  5. Carlos L.May 16, 2022
  6. Junio C HamanoMay 16, 2022
  7. Paul EggertMay 17, 2022
  8. Junio C HamanoMay 16, 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.