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

Re: [Janitors] value could be NULL in config parser

From
GSGovind Salinas <govind@sophiasuchtig.com>
Date
Feb 9, 2008, 01:20 UTC
Message-ID
<5d46db230802081720x122a807do6c63b6b3e435b4c5@mail.gmail.com>
In-Reply-To
<7v63x0lzhw.fsf@gitster.siamese.dyndns.org>
On 2/8/08, Junio C Hamano <gitster@pobox.com> wrote:
Show 19 quoted lines
> A callback function of git_config() is called when the command
> reads value from .git/config and friends.  The function takes
> two parameters, var and value.  var is never NULL and it is the
> name of the configuration variable found in the file being
> read.  value could be either string or NULL.
>
> A NULL value is boolean "true".  For example, on MS-DOS, you may
> have something like this:
>
>         [core]
>                 autocrlf
>
> and your callback will be called with var = "core.autocrlf" and
> value = NULL in such a case.
>
> If you want to fix them (you do not have to do all of them, and
> if you would like to help, please make one patch per function
> fixed), the procedure is:
>
I think I got all the erroneous ones.  I did

find . -name "*.c" | xargs grep git_config\( | awk '{ idx = index($2, ")"); p = substr($2, 12, idx - 12); print p }' | sort | uniq -u

To try and get a list of all the ones that might need updating. I did notice that most functions never check value for null, but they don't directly access them. They pass them off to other methods. As far as I can tell, some of these methods don't validate the NULL. So they will need to be updated.

Question. Wouldn't it reduce the amount of validation we have to do if whoever is calling back checked null and assigned an empty string? If so, we can probably replace all these patches with one patch.

-Govind
Previous: Govind SalinasNext: Christian Couder
Message 10 of 15 in “[Janitors] value could be NULL in config parser”
  1. Junio C HamanoFeb 8, 2008
  2. archive-tar.c: guard config parser from value=NULLMiklos Vajna, Feb 8, 2008
  3. builtin-gc.c: guard config parser from value=NULLMiklos Vajna, Feb 8, 2008
  4. remote.c: guard config parser from value=NULLMiklos Vajna, Feb 8, 2008
  5. Michele BallabioFeb 8, 2008
  6. setup.c: guard config parser from value=NULLMiklos Vajna, Feb 8, 2008
  7. Michele BallabioFeb 8, 2008
  8. Miklos VajnaFeb 8, 2008
  9. Govind SalinasFeb 8, 2008
  10. Govind SalinasFeb 9, 2008
  11. Christian CouderFeb 9, 2008
  12. Junio C HamanoFeb 9, 2008
  13. Christian CouderFeb 9, 2008
  14. Christian CouderFeb 9, 2008
  15. Govind SalinasFeb 9, 2008

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.