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

Re: [PATCH] check-ignore: --non-matching without --verbose

From
CSCarl Smedstad <carl.smedstad@protonmail.com>
Date
May 24, 2022, 13:06 UTC
Message-ID
<qzzAQ1fG52vlhFocoEqahGa8X0FRYpdAzxAHP6NwLXvMFuu0eZQzoa2ew3b1I31puAx__Cr3I2EZObON40rN0UWKT_rSXY3F0tuPqmh2aNc=@protonmail.com>
In-Reply-To
<362128ff-690d-8dc1-88fd-620f52b14d54@github.com>
Show 7 quoted lines
> This may be better to indicate the behavior as predicated on the
> existence of --verbose:
>
> 	If `--verbose` is enabled, then all paths are listed along
> 	with an indicator (`::`) that no matching pattern was found.
> 	Without `--verbose`, list only the paths that do not match
> 	any pattern.

Good point. I've adopted you changes but made some slight changes to the first line:

	If `--verbose` is enabled, list both matching and non-matching
	paths (non-matching paths along with the indicator `::`). Without
	`--verbose`, list only the paths that do not match any pattern.
Show 20 quoted lines
> These three blocks all call the same code line. So really you want
> to avoid a single case:
>
> 	if (!quiet &&
> 	    ((verbose && (show_non_matching || pattern)) ||
> 	     (!verbose && !!show_non_matching != !!pattern)))
>
> This is the most direct way to write what you had above. However,
> we could do this more simply:
>
> 	/* If --non-matching, then show if verbose or the pattern is missing. */
> 	if (!quiet && show_non_matching && (verbose || !pattern))
> 		output_pattern(...);
>
> 	/* If not --non-matching, then show if the pattern exists. */
> 	if (!quiet && !show_non_matching && pattern)
> 		output_pattern(...);
>
> Hopefully that's a bit easier to parse. I believe it is
> equivalent.

That is indeed equivalent and a lot easier to read. Implemented the changes in full. Thanks!

Previous: Derrick StoleeNext: Carl Smedstad via GitGitGadget
Message 7 of 9 in “check-ignore: --non-matching without --verbose”
  1. check-ignore: --non-matching without --verboseCarl Smedstad via GitGitGadget, May 23, 2022
  2. Junio C HamanoMay 23, 2022
  3. Carl SmedstadMay 24, 2022
  4. Junio C HamanoMay 24, 2022
  5. Ævar Arnfjörð BjarmasonMay 24, 2022
  6. Derrick StoleeMay 23, 2022
  7. Carl SmedstadMay 24, 2022
  8. check-ignore: --non-matching without --verboseCarl Smedstad via GitGitGadget, May 24, 2022
  9. Junio C HamanoMay 24, 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.