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

Re: [PATCH v3?] Add global and system-wide gitattributes

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 30, 2010, 21:11 UTC
Message-ID
<7vbp8jerfq.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7voccjesk7.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>
>> I don't understand why this breaks the test. It seems blame
>> --encoding=UTF-8 relies on the fact that the i18n section of the
>> configuration is not loaded.
>
> That's interesting; I haven't traced the codepath involved, but I do not
> think "configuration is not loaded" is the issue. "Reading either before
> the main codepath is ready, or more likely overwriting/destroying what the
> main codepath has read it by re-reading the configuration" may be.

I think that hunch is correct. A typical way we default to hardcoded value, overridable by configuration file, and then further use command line to override that, is for the main codepath to do the following in this order:

 - call git_config(git_appropriate_config); this changes the variables
   (with possibly hardcoded default) defined in environment.c;
 - parse command line options and override the variable;
 - use the variable at runtime.

This obviously relies on the main codepath having _total_ control of the calls made to git_config(). If you call git_config(git_default_config) when an attribute is asked for for the first time (which would be way after all of the above happened) behind the main codepath's back, you will of course break things. In the "blame" case, aren't you stomping on git_log_output_encoding?

The correct solution would be twofold, but the latter is rather painful:
 - The call from the bootstrap_attr_stack should use a callback that reads
   only the attribute file location configuration and _nothing else_.
   Also I do not think the parsing of this configuration variable needs to
   be in git_default_config() to begin with, if you are reading it from
   the bootstrap codepath on demand anyway, and not relying on the main
   codepath of any particular program to be calling on git_config().
 - The way programs (this is not limited to blame and other rev-list
   machinery users) implement the "use configured values but let command
   line override them" need to be changed.
   
   One possibility is to copy the values determined by reading the config
   and the command line to their own variables, so that later random call
   to git_config() won't stomp on the actual values to be used.  This is
   painful as environment.c variables are _meant_ to be easily usable as
   global variables and copying them away (which means they now need to be
   passed around throughout the callchain in the various APIs) defeats
   the whole point of having them.
Previous: Junio C HamanoNext: Matthieu Moy
Message 18 of 36 in “Add global and system-wide gitattributes”
  1. Add global and system-wide gitattributesPetr Onderka, Aug 11, 2010
  2. Henrik GrubbströmAug 11, 2010
  3. Petr OnderkaAug 11, 2010
  4. Matthieu MoyAug 11, 2010
  5. Junio C HamanoAug 11, 2010
  6. Petr OnderkaAug 16, 2010
  7. Add global and system-wide gitattributesPetr Onderka, Aug 16, 2010
  8. Štěpán NěmecAug 25, 2010
  9. Matthieu MoyAug 28, 2010
  10. Junio C HamanoAug 30, 2010
  11. Štěpán NěmecAug 30, 2010
  12. Matthieu MoyAug 28, 2010
  13. core.attributesfile: a fix, a simplification, and a testMatthieu Moy, Aug 28, 2010
  14. Štěpán NěmecAug 29, 2010
  15. Junio C HamanoAug 30, 2010
  16. Matthieu MoyAug 30, 2010
  17. Junio C HamanoAug 30, 2010
  18. Junio C HamanoAug 30, 2010
  19. Matthieu MoyAug 30, 2010
  20. 1/3 tests: factor HOME=$(pwd) in test-lib.shMatthieu Moy, Aug 30, 2010
  21. Ævar Arnfjörð BjarmasonAug 31, 2010
  22. Ævar Arnfjörð BjarmasonSep 1, 2010
  23. Junio C HamanoSep 1, 2010
  24. Ævar Arnfjörð BjarmasonSep 1, 2010
  25. Matthieu MoySep 1, 2010
  26. 2/3 don't write to git_log_output_encoding outside git_config()Matthieu Moy, Aug 30, 2010
  27. Matthieu MoySep 2, 2010
  28. Junio C HamanoSep 2, 2010
  29. 3/3 Add global and system-wide gitattributesMatthieu Moy, Aug 30, 2010
  30. Matthieu MoyAug 31, 2010
  31. Add global and system-wide gitattributesMatthieu Moy, Aug 31, 2010
  32. Junio C HamanoAug 31, 2010
  33. tests: factor HOME=$(pwd) in test-lib.shMatthieu Moy, Aug 30, 2010
  34. Ævar Arnfjörð BjarmasonAug 30, 2010
  35. Matthieu MoyAug 30, 2010
  36. Ævar Arnfjörð BjarmasonAug 30, 2010

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.