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

Re: [PATCH 05/10] setup: use the default algorithm to initialize repo format

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 20, 2025, 21:05 UTC
Message-ID
<xmqqqzze15ug.fsf@gitster.g>
In-Reply-To
<aFXEgLRLRdbaPOb2@fruit.crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 13 quoted lines
>> > -	if (format->version == -1)
>> > +	if (format->version == -1) {
>> 
>> And if there is no core.repositoryformatversion set, we will come
>> here.  According to the comment before handle_extension_v0(), some
>> extensions.* should still be honored even in such a repository, and
>> the above call to git_config_from_file() should have handled them
>> just fine.
>> 
>> However, I do not understand why we clear all of what we read with
>> another call to clear_repository_format() here.
>
> Because this is the case where there's no config file.  

But my worries come from that .version == -1 does not necessarily mean a missing config. Missing config will give .version == -1 but the opposite may not be true, no?

> If nobody
> bothered to write a configuration file, then we want to reset everything
> to the default.

True. If config file is missing, yes, .version will be -1 and clearing may make sense. But if the file is missing, we wouldn't have anything to "reset to the default" because we wouldn't have read anything, so what clear_repository_format() call initialized to the default before we read config from file would still be there, no?

Show 5 quoted lines
> I don't know what we do if we have a repository with a config file and
> no version, but literally every repository since Git 0.99.3 (I believe)
> has core.repositoryformatversion written into the repo.  I'm certain
> that the behaviour we'd want if nobody specified one was to do the most
> compatible thing, so the defaults seem prudent.

If our assumption is that no config file in repositories we care about should lack core.repositoryformatversion, then what you wrote above makes perfect sense, but then we should probably update the comment before the handle_extension_v0() because it is stale. The new semantics is that any extension.* found in a config file that lacks core.repositoryformatversion will be ignored with the new code, right? If that is our intention, it should be documented.

The current code will not clear, so there is a change in behaviour. I do not know if we particularly care about this behaviour change, though.

> The reason we need to read all the extensions is that different config
> options aren't ordered ...

Yes, that is where my "somewhat questionable" comes from. We'd have to read everything in and then refrain from touching a repository with extensions that should not exist (i.e., the ones we do not understand, or the ones that should not be used with the stated format version) in verify_repository_format() as you said.

Thanks.
Previous: brian m. carlsonNext: brian m. carlson
Message 20 of 47 in “Add SHA-256 by default as a breaking change”
  1. 00/10 Add SHA-256 by default as a breaking changebrian m. carlson, Jun 20, 2025
  2. 01/10 hash: add a constant for the default hash algorithmbrian m. carlson, Jun 20, 2025
  3. 03/10 builtin: use default hash when outside a repositorybrian m. carlson, Jun 20, 2025
  4. Junio C HamanoJun 20, 2025
  5. Patrick SteinhardtJul 1, 2025
  6. brian m. carlsonJul 1, 2025
  7. Patrick SteinhardtJul 2, 2025
  8. 04/10 Use original hash for legacy formatsbrian m. carlson, Jun 20, 2025
  9. Junio C HamanoJun 20, 2025
  10. brian m. carlsonJun 20, 2025
  11. Junio C HamanoJun 20, 2025
  12. Patrick SteinhardtJul 1, 2025
  13. 02/10 hash: add a constant for the original hash algorithmbrian m. carlson, Jun 20, 2025
  14. Junio C HamanoJun 20, 2025
  15. brian m. carlsonJun 20, 2025
  16. Patrick SteinhardtJul 1, 2025
  17. 05/10 setup: use the default algorithm to initialize repo formatbrian m. carlson, Jun 20, 2025
  18. Junio C HamanoJun 20, 2025
  19. brian m. carlsonJun 20, 2025
  20. Junio C HamanoJun 20, 2025
  21. 08/10 t4042: choose the built-in hash outside of a repobrian m. carlson, Jun 20, 2025
  22. 07/10 t1007: choose the built-in hash outside of a repobrian m. carlson, Jun 20, 2025
  23. 06/10 t: default to compile-time default hash if not setbrian m. carlson, Jun 20, 2025
  24. 09/10 t5300: choose the built-in hash outside of a repobrian m. carlson, Jun 20, 2025
  25. 10/10 Enable SHA-256 by default in breaking changes modebrian m. carlson, Jun 20, 2025
  26. Junio C HamanoJun 20, 2025
  27. brian m. carlsonJun 20, 2025
  28. Junio C HamanoJun 20, 2025
  29. brian m. carlsonJun 20, 2025
  30. Junio C HamanoJun 20, 2025
  31. brian m. carlsonJun 20, 2025
  32. Patrick SteinhardtJul 1, 2025
  33. 00/11 Add SHA-256 by default as a breaking changebrian m. carlson, Jul 1, 2025
  34. 02/11 hash: add a constant for the legacy hash algorithmbrian m. carlson, Jul 1, 2025
  35. 01/11 hash: add a constant for the default hash algorithmbrian m. carlson, Jul 1, 2025
  36. 04/11 Use legacy hash for legacy formatsbrian m. carlson, Jul 1, 2025
  37. 03/11 builtin: use default hash when outside a repositorybrian m. carlson, Jul 1, 2025
  38. 06/11 t: default to compile-time default hash if not setbrian m. carlson, Jul 1, 2025
  39. 05/11 setup: use the default algorithm to initialize repo formatbrian m. carlson, Jul 1, 2025
  40. 08/11 t4042: choose the built-in hash outside of a repobrian m. carlson, Jul 1, 2025
  41. 07/11 t1007: choose the built-in hash outside of a repobrian m. carlson, Jul 1, 2025
  42. 10/11 help: add a build option for default hashbrian m. carlson, Jul 1, 2025
  43. 11/11 Enable SHA-256 by default in breaking changes modebrian m. carlson, Jul 1, 2025
  44. 09/11 t5300: choose the built-in hash outside of a repobrian m. carlson, Jul 1, 2025
  45. Junio C HamanoJul 1, 2025
  46. Patrick SteinhardtJul 2, 2025
  47. Kristoffer HaugsbakkJul 2, 2025

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.