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

[PATCH] init-db: init the_repository->hash_algo early from GIT_DEFAULT_HASH

From
Han-Wen Nienhuys via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 26, 2020, 19:39 UTC
Message-ID
<pull.924.git.git.1606419582190.gitgitgadget@gmail.com>
From: Han-Wen Nienhuys <hanwen@google.com>

The reftable backend needs to know the hash algorithm for writing the initialization hash table.

The initial reftable contains a symref HEAD => "main" (or "master"), which is agnostic to the size of hash value, but this is an exceptional circumstance, and the reftable library does not cater for this exception. It insists that all tables in the stack have a consistent format ID for the hash algorithm.

Call set_repo_hash_algo directly after reading out GIT_DEFAULT_HASH.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
    init-db: init the_repository->hash_algo early from GIT_DEFAULT_HASH
    
    The reftable backend needs to know the hash algorithm for writing the
    initialization hash table.
    
    The initial reftable contains a symref HEAD => "main" (or "master"),
    which is agnostic to the size of hash value, but this is an exceptional
    circumstance, and the reftable library does not cater for this
    exception. It insists that all tables in the stack have a consistent
    format ID for the hash algorithm.
    
    Call set_repo_hash_algo directly after reading out GIT_DEFAULT_HASH.
    
    Signed-off-by: Han-Wen Nienhuys hanwen@google.com [hanwen@google.com]
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-924%2Fhanwen%2Fset-hash-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-924/hanwen/set-hash-v1
Pull-Request: https://github.com/git/git/pull/924
 builtin/init-db.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 01bc648d41..5c8c67fec6 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -391,6 +391,7 @@ static void validate_hash_algorithm(struct repository_format *repo_fmt, int hash
 			die(_("unknown hash algorithm '%s'"), env);
 		repo_fmt->hash_algo = env_algo;
 	}
+	repo_set_hash_algo(the_repository, repo_fmt->hash_algo);
 }
 
 int init_db(const char *git_dir, const char *real_git_dir,

base-commit: faefdd61ec7c7f6f3c8c9907891465ac9a2a1475
-- 
gitgitgadget
Next: Junio C Hamano
Message 1 of 6 in “init-db: init the_repository->hash_algo early from GIT_DEFAULT_HASH”
  1. init-db: init the_repository->hash_algo early from GIT_DEFAULT_HASHHan-Wen Nienhuys via GitGitGadget, Nov 26, 2020
  2. Junio C HamanoDec 1, 2020
  3. Han-Wen NienhuysDec 3, 2020
  4. Junio C HamanoDec 3, 2020
  5. Han-Wen NienhuysDec 7, 2020
  6. Junio C HamanoDec 7, 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.