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

Re: [PATCH] log: require --grep for --invert-grep and --all-match, fix segfault

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Oct 10, 2022, 18:48 UTC
Message-ID
<221010.86o7ujpl44.gmgdl@evledraar.gmail.com>
In-Reply-To
<xmqq35bv4lns.fsf@gitster.g>
On Mon, Oct 10 2022, Junio C Hamano wrote:
Show 26 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>>
>>> Neither the "--invert-grep" option added in [1] nor the earlier
>>> "--all-match" option added in [2] were intended to be used
>>> stand-alone.
>>
>> Mostly yes, but with "to be used" -> "to take effect".
>>
>> "[alias] lga = log --all-match" would be equivalent to "log"
>> unless the command line starts talking about "--grep", which is
>> quite handy.
>>
>> So the real fix would be not to forbid the standalone passing of the
>> option to the command, but to fix the over-eager freeing of an
>> unallocated resource, introduced more recently, I would suspect.
>
> On the other hand, I do not think "--invert-grep" is useful in the
> same way.  The only usage I can think of is to omit merges by
> looking for substring "^Merge", but then we already have a more
> robust "--no-merges" option for that purpose.
>
> But both uses the same mechanism, I would say treating them the
> same, i.e. silently ignoring these when --grep is not given, would
> be the most sensible.
The rationale for changing it this way is that the documentaion says:
	
	--all-match::
	        Limit the commits output to ones that match all given `--grep`,
	        instead of ones that match at least one.
	--invert-grep::
	        Limit the commits output to ones with log message that do not
	        match the pattern specified with `--grep=<pattern>`.
Especially as we also say:
	--grep-reflog=<pattern>::
	        Limit the commits output to ones with reflog entries that
        	match the specified pattern (regular expression) [...]

I.e. pretty much the same wording, but there we'll die if the corresponding other option is omitted, as the context shows.

Maybe we want to post-hoc say we'd like to support it, in which case some plasting over the issue (e.g. in the direction of Taylor's fix) would do it.

Previous: Junio C HamanoNext: Taylor Blau
Message 8 of 18 in “Git BUG 2.37.3 and 2.38.0”
  1. orygawOct 10, 2022
  2. rsbecker@nexbridge.comOct 10, 2022
  3. Taylor BlauOct 10, 2022
  4. Junio C HamanoOct 10, 2022
  5. log: require --grep for --invert-grep and --all-match, fix segfaultÆvar Arnfjörð Bjarmason, Oct 10, 2022
  6. Junio C HamanoOct 10, 2022
  7. Junio C HamanoOct 10, 2022
  8. Ævar Arnfjörð BjarmasonOct 10, 2022
  9. Taylor BlauOct 10, 2022
  10. grep.c: remove "extended" in favor of "pattern_expression", fix segfaultÆvar Arnfjörð Bjarmason, Oct 11, 2022
  11. Junio C HamanoOct 11, 2022
  12. 0/2 grep: tolerate NULL argument to free_grep_expr()Taylor Blau, Oct 10, 2022
  13. 1/2 t4202: demonstrate `git log --invert-grep` segfaultTaylor Blau, Oct 10, 2022
  14. 2/2 grep.c: tolerate NULL grep_expr in free_pattern_expr()Taylor Blau, Oct 10, 2022
  15. Junio C HamanoOct 10, 2022
  16. Taylor BlauOct 10, 2022
  17. Junio C HamanoOct 10, 2022
  18. Taylor BlauOct 10, 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.