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

Posible bug with GIT_DEFAULT_HASH during clone

From
Matheus Tavares <matheus.bernardino@usp.br>
Date
Sep 11, 2020, 15:17 UTC
Message-ID
<20200911151717.43475-1-matheus.bernardino@usp.br>
Hi, everyone

Documentation/git.txt mentions that GIT_DEFAULT_HASH is ignored during clone, but I think it may not be *totally* ignored, sometimes leaving the config file on the cloned repo in an inconsistent state.

To reproduce this (tested with current `master` and `seen`):

git init test echo F>test/F git -C test add F git -C test commit -m F export GIT_DEFAULT_HASH=sha256 git clone test test-clone git -C test-clone status

Which outputs:
fatal: repo version is 0, but v1-only extensions found:
        objectformat
From what I could see under gdb, the steps leading to this are:
- First, this call chain gets the GIT_DEFAULT_HASH value:
  cmd_clone() > init_db() > validate_hash_algorithm().
- Then, init_db() calls create_default_files(), which calls
  initialize_repository_version() with GIT_HASH_SHA256, setting these
  configs:
  * extensions.objectFormat=sha256
  * core.repositoryFormatVersion=1
- Finally, cmd_clone() later uses the return of
  transport_get_hash_algo() to call initialize_repository_version()
  again, but with GIT_HASH_SHA1, setting:
  * core.repositoryFormatVersion=0

So we end up with the repository format version as 0 but the objectFormat extension is present.

Thanks, Matheus

Next: brian m. carlson
Message 1 of 15 in “Posible bug with GIT_DEFAULT_HASH during clone”
  1. Matheus TavaresSep 11, 2020
  2. brian m. carlsonSep 11, 2020
  3. builtin/clone: avoid failure with GIT_DEFAULT_HASHbrian m. carlson, Sep 11, 2020
  4. Taylor BlauSep 12, 2020
  5. brian m. carlsonSep 12, 2020
  6. Junio C HamanoSep 14, 2020
  7. Junio C HamanoSep 14, 2020
  8. brian m. carlsonSep 15, 2020
  9. builtin/clone: avoid failure with GIT_DEFAULT_HASHbrian m. carlson, Sep 15, 2020
  10. Junio C HamanoSep 15, 2020
  11. brian m. carlsonSep 15, 2020
  12. builtin/clone: avoid failure with GIT_DEFAULT_HASHbrian m. carlson, Sep 20, 2020
  13. Junio C HamanoSep 21, 2020
  14. brian m. carlsonSep 22, 2020
  15. Junio C HamanoSep 22, 2020

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.