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

Re: [RFC/PATCH] pager.c: replace git_config with git_config_get_string

From
Karsten Blees <karsten.blees@gmail.com>
Date
Jun 27, 2014, 16:57 UTC
Message-ID
<53ADA26E.8030801@gmail.com>
In-Reply-To
<vpqr42afty5.fsf@anie.imag.fr>
Am 27.06.2014 13:55, schrieb Matthieu Moy:
Show 12 quoted lines
> Karsten Blees <karsten.blees@gmail.com> writes:
> 
>> If for some reason a config string is accessed after config_cache_free()
>> (which would be a bug), you won't notice if strings are xstrdup()ed (i.e. git
>> will continue to run with some invalid configuration). This is IMO much worse
>> than failing with segfault.
> 
> I disagree. In most case, continuing to use the old config value is the
> right thing.
> 
> First, config_cache_free() is called whenever _any_ configuration
> variable is set.

This is illogical. An API should do the right thing, and if the right thing is to keep the old values, as you pointed out, then setting a config value shouldn't invalidate the cache (at least not automatically).

I can think of only git-clone and git-init that may want to refresh the global config cache, otherwise, config_cache_free() should probably _never_ be called. Least of all as a side effect of git_config_set_multivar_in_file(), which is used to write all kinds of unrelated files that just happen to have config-file format (e.g. '.gitmodules', '.git/sequencer/opts').

> So, setting "core.foo" also invalidates "core.bar" in
> the cache, while a user of "core.bar" could continue working with the
> old, unchanged value.

But a user of an xstrdup()ed copy of "core.foo" would also continue to work with the old value. So if everyone keeps copies of config strings, invalidating the cache when setting a value has no effect. We could just as well not invalidate the cache and not xstrdup() strings.

Perhaps we should see this as an opportunity to get rid of all the memory leaks in current config code (each string value defined in system / global config and overridden locally will currently be leaked with the 'standard' xstrdup() pattern).

Previous: Matthieu MoyNext: Matthieu Moy
Message 31 of 41 in “alias.c: replace git_config with git_config_get_string”
  1. alias.c: replace git_config with git_config_get_stringTanay Abhra, Jun 23, 2014
  2. branch.c: replace git_config with git_config_get_stringTanay Abhra, Jun 23, 2014
  3. Eric SunshineJun 25, 2014
  4. Tanay AbhraJun 26, 2014
  5. Eric SunshineJun 29, 2014
  6. imap-send.c: replace git_config with git_config_get_stringTanay Abhra, Jun 23, 2014
  7. Eric SunshineJun 25, 2014
  8. Tanay AbhraJun 26, 2014
  9. Matthieu MoyJun 26, 2014
  10. Karsten BleesJun 26, 2014
  11. notes-util.c: replace git_config with git_config_get_stringTanay Abhra, Jun 23, 2014
  12. Eric SunshineJun 25, 2014
  13. Tanay AbhraJun 26, 2014
  14. Eric SunshineJun 29, 2014
  15. Karsten BleesJun 30, 2014
  16. Eric SunshineJun 30, 2014
  17. Karsten BleesJun 30, 2014
  18. Tanay AbhraJun 30, 2014
  19. Karsten BleesJun 30, 2014
  20. Tanay AbhraJun 30, 2014
  21. Junio C HamanoJun 30, 2014
  22. Matthieu MoyJul 1, 2014
  23. notes.c: replace git_config with git_config_get_stringTanay Abhra, Jun 23, 2014
  24. Eric SunshineJun 25, 2014
  25. Tanay AbhraJun 26, 2014
  26. pager.c: replace git_config with git_config_get_stringTanay Abhra, Jun 23, 2014
  27. Eric SunshineJun 25, 2014
  28. Tanay AbhraJun 26, 2014
  29. Karsten BleesJun 26, 2014
  30. Matthieu MoyJun 27, 2014
  31. Karsten BleesJun 27, 2014
  32. Matthieu MoyJun 27, 2014
  33. Karsten BleesJun 28, 2014
  34. Matthieu MoyJun 28, 2014
  35. Karsten BleesJun 28, 2014
  36. Matthieu MoyJun 29, 2014
  37. Jonathan NiederJun 23, 2014
  38. Tanay AbhraJun 24, 2014
  39. Eric SunshineJun 25, 2014
  40. Tanay AbhraJun 26, 2014
  41. Matthieu MoyJun 26, 2014

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.