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

Re: [PATCHv2 3/6] t7810-grep: test multiple --author with --all-match

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Sep 14, 2012, 08:14 UTC
Message-ID
<5052E756.2040605@drmicha.warpmail.net>
In-Reply-To
<7vwqzx4i9i.fsf@alter.siamese.dyndns.org>
Junio C Hamano venit, vidit, dixit 14.09.2012 01:26:
Show 66 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
>> One possible improvement we can make is to parse the command line in
>> the last example with "--all-match" to
>>
>>     [all-match]
>>     (or
>>      pattern_body<body>commit
>>      (or
>>       pattern_body<body>tag
>>       (or
>>        pattern_head<head 1>Linus
>>        (or
>>         pattern_head<head 0>Junio
>>         true
>>        )
>>       )
>>      )
>>     )
>>
>> so that the backbone becomes
>>
>>  - Mentions commit,
>>  - Mentions tag,
>>  - Committed by Linus,
>>  - Authored by Junio
>>
>> to require that both commit and tag are mentioned in the message.
> 
> And this is an attempt to do exactly that.  Earlier, when we have
> both header expression (which by the way has to be an OR node by
> construction) and pattern expression (which could be anything), we
> created a top-level OR node (again, look at this as if you are
> reading LISP),
> 
>            OR
>         /        \
>        /          \
>    pattern            OR
>      / \           /     \
>     .....    committer    OR
>                          /   \ 
>                      author   TRUE
> 
> in other words, the three elements on the top-level backbone are
> "pattern", "committer" and "author"; when there are more than one
> elements in the "pattern", the top-level node of it is OR, so that
> node is inspected by "all-match", hence the result ends up ignoring
> the "--all-match" given from the command line.
> 
> This patch turns it into
> 
> 	     OR
>           /      \
>          /         \
>         /              OR
>     committer        /    \
>                  author    \
>                            pattern
> 
> when "--all-match" was given from the command line, so that the
> "committer", "author" and elements on the top-level backbone in
> "pattern" form the top-level backbone of the resulting expression to
> be inspected by the "all-match" logic.
> 
> Does this pass the expect-failure test in your [PATCH 5/6]?
Just a quick heads up:

I merged 38ed8ef (log --grep/--author: honor --all-match honored for multiple --grep patterns, 2012-09-13) from pu into my test branch, and this fixes what I had marked as known failure there. Thanks!

[I still have to figure out the logic, but begin to understand that "(OR...) and "(AND...)" are linewise, and all-match is a bufferwise AND or something. Now, what is "*or*" ...]

Show 41 quoted lines
>  grep.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git c/grep.c w/grep.c
> index be15c47..925aa92 100644
> --- c/grep.c
> +++ w/grep.c
> @@ -476,6 +476,22 @@ static struct grep_expr *prep_header_patterns(struct grep_opt *opt)
>  	return header_expr;
>  }
>  
> +static struct grep_expr *grep_splice_or(struct grep_expr *x, struct grep_expr *y)
> +{
> +	struct grep_expr *z = x;
> +
> +	while (x) {
> +		assert(x->node == GREP_NODE_OR);
> +		if (x->u.binary.right &&
> +		    x->u.binary.right->node == GREP_NODE_TRUE) {
> +			x->u.binary.right = y;
> +			break;
> +		}
> +		x = x->u.binary.right;
> +	}
> +	return z;
> +}
> +
>  static void compile_grep_patterns_real(struct grep_opt *opt)
>  {
>  	struct grep_pat *p;
> @@ -510,6 +526,9 @@ static void compile_grep_patterns_real(struct grep_opt *opt)
>  
>  	if (!opt->pattern_expression)
>  		opt->pattern_expression = header_expr;
> +	else if (opt->all_match)
> +		opt->pattern_expression = grep_splice_or(header_expr,
> +							 opt->pattern_expression);
>  	else
>  		opt->pattern_expression = grep_or_expr(opt->pattern_expression,
>  						       header_expr);
> 
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 43 in “rev-list/log: document logic with several limiting options”
  1. rev-list/log: document logic with several limiting optionsMichael J Gruber, Sep 11, 2012
  2. Junio C HamanoSep 11, 2012
  3. Michael J GruberSep 12, 2012
  4. Junio C HamanoSep 12, 2012
  5. Junio C HamanoSep 12, 2012
  6. 0/6 rev-list/log: document logic with several limiting optionsMichael J Gruber, Sep 13, 2012
  7. Junio C HamanoSep 13, 2012
  8. 1/6 t7810-grep: bring log --grep tests in common formMichael J Gruber, Sep 13, 2012
  9. 2/6 t7810-grep: test multiple --grep with and without --all-matchMichael J Gruber, Sep 13, 2012
  10. 3/6 t7810-grep: test multiple --author with --all-matchMichael J Gruber, Sep 13, 2012
  11. Junio C HamanoSep 13, 2012
  12. Junio C HamanoSep 13, 2012
  13. Michael J GruberSep 14, 2012
  14. Junio C HamanoSep 14, 2012
  15. 4/6 t7810-grep: test interaction of multiple --grep and --author optionsMichael J Gruber, Sep 13, 2012
  16. 5/6 t7810-grep: test --all-match with multiple --grep and --author optionsMichael J Gruber, Sep 13, 2012
  17. 6/6 rev-list/log: document logic with several limiting optionsMichael J Gruber, Sep 13, 2012
  18. Junio C HamanoSep 13, 2012
  19. Junio C HamanoSep 14, 2012
  20. Junio C HamanoSep 14, 2012
  21. 00/11 rev-list/log: document logic with several limiting optionsMichael J Gruber, Sep 14, 2012
  22. Junio C HamanoSep 14, 2012
  23. 01/11 grep: teach --debug option to dump the parse treeMichael J Gruber, Sep 14, 2012
  24. Junio C HamanoSep 14, 2012
  25. 02/11 log: name --debug-grep option like in the commit messageMichael J Gruber, Sep 14, 2012
  26. 03/11 grep: show --debug output only onceMichael J Gruber, Sep 14, 2012
  27. Junio C HamanoSep 14, 2012
  28. 04/11 log --grep/--author: honor --all-match honored for multiple --grep patternsMichael J Gruber, Sep 14, 2012
  29. 05/11 log: document use of multiple commit limiting optionsMichael J Gruber, Sep 14, 2012
  30. 06/11 fixup! log: document use of multiple commit limiting optionsMichael J Gruber, Sep 14, 2012
  31. Junio C HamanoSep 14, 2012
  32. 07/11 t7810-grep: bring log --grep tests in common formMichael J Gruber, Sep 14, 2012
  33. 08/11 t7810-grep: test multiple --grep with and without --all-matchMichael J Gruber, Sep 14, 2012
  34. 09/11 t7810-grep: test multiple --author with --all-matchMichael J Gruber, Sep 14, 2012
  35. Junio C HamanoSep 14, 2012
  36. 10/11 t7810-grep: test interaction of multiple --grep and --author optionsMichael J Gruber, Sep 14, 2012
  37. 11/11 t7810-grep: test --all-match with multiple --grep and --author optionsMichael J Gruber, Sep 14, 2012
  38. Junio C HamanoSep 14, 2012
  39. Michael J GruberSep 13, 2012
  40. Junio C HamanoSep 13, 2012
  41. Michael J GruberSep 14, 2012
  42. Junio C HamanoSep 14, 2012
  43. Michael J GruberSep 14, 2012

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.