Merge branch 'bc/sha-256-part-1-of-4'

SHA-256 transition continues.

* bc/sha-256-part-1-of-4: (22 commits)
  fast-import: add options for rewriting submodules
  fast-import: add a generic function to iterate over marks
  fast-import: make find_marks work on any mark set
  fast-import: add helper function for inserting mark object entries
  fast-import: permit reading multiple marks files
  commit: use expected signature header for SHA-256
  worktree: allow repository version 1
  init-db: move writing repo version into a function
  builtin/init-db: add environment variable for new repo hash
  builtin/init-db: allow specifying hash algorithm on command line
  setup: allow check_repository_format to read repository format
  t/helper: make repository tests hash independent
  t/helper: initialize repository if necessary
  t/helper/test-dump-split-index: initialize git repository
  t6300: make hash algorithm independent
  t6300: abstract away SHA-1-specific constants
  t: use hash-specific lookup tables to define test constants
  repository: require a build flag to use SHA-256
  hex: add functions to parse hex object IDs in any algorithm
  hex: introduce parsing variants taking hash algorithms
  ...
This commit is contained in:
Junio C Hamano
2020-03-26 17:11:20 -07:00
28 changed files with 624 additions and 142 deletions

View File

@ -74,6 +74,11 @@ static void git_hash_sha1_init(git_hash_ctx *ctx)
git_SHA1_Init(&ctx->sha1);
}
static void git_hash_sha1_clone(git_hash_ctx *dst, const git_hash_ctx *src)
{
git_SHA1_Clone(&dst->sha1, &src->sha1);
}
static void git_hash_sha1_update(git_hash_ctx *ctx, const void *data, size_t len)
{
git_SHA1_Update(&ctx->sha1, data, len);
@ -90,6 +95,11 @@ static void git_hash_sha256_init(git_hash_ctx *ctx)
git_SHA256_Init(&ctx->sha256);
}
static void git_hash_sha256_clone(git_hash_ctx *dst, const git_hash_ctx *src)
{
git_SHA256_Clone(&dst->sha256, &src->sha256);
}
static void git_hash_sha256_update(git_hash_ctx *ctx, const void *data, size_t len)
{
git_SHA256_Update(&ctx->sha256, data, len);
@ -105,6 +115,11 @@ static void git_hash_unknown_init(git_hash_ctx *ctx)
BUG("trying to init unknown hash");
}
static void git_hash_unknown_clone(git_hash_ctx *dst, const git_hash_ctx *src)
{
BUG("trying to clone unknown hash");
}
static void git_hash_unknown_update(git_hash_ctx *ctx, const void *data, size_t len)
{
BUG("trying to update unknown hash");
@ -123,6 +138,7 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
0,
0,
git_hash_unknown_init,
git_hash_unknown_clone,
git_hash_unknown_update,
git_hash_unknown_final,
NULL,
@ -136,6 +152,7 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
GIT_SHA1_HEXSZ,
GIT_SHA1_BLKSZ,
git_hash_sha1_init,
git_hash_sha1_clone,
git_hash_sha1_update,
git_hash_sha1_final,
&empty_tree_oid,
@ -149,6 +166,7 @@ const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
GIT_SHA256_HEXSZ,
GIT_SHA256_BLKSZ,
git_hash_sha256_init,
git_hash_sha256_clone,
git_hash_sha256_update,
git_hash_sha256_final,
&empty_tree_oid_sha256,