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

Re: [PATCH 4/5] grep: introduce new config option to include untracked files

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 19, 2024, 14:32 UTC
Message-ID
<xmqqil1is35i.fsf@gitster.g>
In-Reply-To
<923c5f84c44a195d6ba08503e28851af@manjaro.org>
Dragan Simic <dsimic@manjaro.org> writes:
Show 9 quoted lines
>>> +	if (use_index && !cached)
>>> +		git_config_get_bool("grep.includeuntracked", &untracked);
>> Can this ever return an error?  E.g.
>> 	[grep] includeuntracked = "not really"
>
> After a brief inspection of the code in cache.c, git_config_get_bool()
> always returns either 0 or 1, so we should be fine.  Thus, any
> strangeness in a configuration file would end up not enabling
> this option.
If that were the case, then it is not "fine".

When the user triggered an operation which *requires* us to parse and interpret the meaning of an entry in their configuration file correctly in order to carry it out, and if that entry has a value that we do not consider valid, we should notice and complain, before saying "Nah, this I do not understand, so I'll do one of the two things I would have done if the value were understandable and would not tell the user which one I did".

What makes it fine int his case is that git_config_get_bool() dies when the given value is not a Boolean ;-). The returned value from the function can be used to tell if the variable does not exist and the caller should decide to stuff some default value to &untracked but in this case you do not need to.

Previous: Dragan SimicNext: Dragan Simic
Message 8 of 22 in “New config option for git-grep to include untracked files”
  1. 0/5 New config option for git-grep to include untracked filesDragan Simic, Mar 18, 2024
  2. 3/5 grep docs: describe --no-index furtherDragan Simic, Mar 18, 2024
  3. Junio C HamanoMar 19, 2024
  4. Dragan SimicMar 19, 2024
  5. 4/5 grep: introduce new config option to include untracked filesDragan Simic, Mar 18, 2024
  6. Junio C HamanoMar 19, 2024
  7. Dragan SimicMar 19, 2024
  8. Junio C HamanoMar 19, 2024
  9. Dragan SimicMar 19, 2024
  10. 2/5 grep docs: describe --recurse-submodules further and improve formatting a bitDragan Simic, Mar 18, 2024
  11. Eric SunshineMar 18, 2024
  12. Dragan SimicMar 18, 2024
  13. 1/5 grep: perform some minor code and comment cleanupsDragan Simic, Mar 18, 2024
  14. Eric SunshineMar 18, 2024
  15. Dragan SimicMar 18, 2024
  16. Junio C HamanoMar 19, 2024
  17. Dragan SimicMar 19, 2024
  18. 5/5 grep docs: describe new config option to include untracked filesDragan Simic, Mar 18, 2024
  19. Junio C HamanoMar 19, 2024
  20. Dragan SimicMar 19, 2024
  21. Junio C HamanoMar 19, 2024
  22. Dragan SimicMar 19, 2024

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.