From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Edward Thomson <ethomson@edwardthomson.com>,
Eric Sunshine <sunshine@sunshineco.com>,
Justin Tobler <jltobler@gmail.com>
Subject: Re: [PATCH v2 3/7] reftable/system: stop depending on "hash.h"
Date: Tue, 12 Nov 2024 14:53:46 +0900 [thread overview]
Message-ID: <xmqqh68d6lqt.fsf@gitster.g> (raw)
In-Reply-To: <745c1a070ddd7180f0ee89c6a1d057a256894599.1731047193.git.ps@pks.im> (Patrick Steinhardt's message of "Fri, 8 Nov 2024 09:17:14 +0100")
Patrick Steinhardt <ps@pks.im> writes:
> diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
> index 3c6107c7ce5..7d86d920970 100644
> --- a/refs/reftable-backend.c
> +++ b/refs/reftable-backend.c
> @@ -15,6 +15,7 @@
> #include "../object.h"
> #include "../path.h"
> #include "../refs.h"
> +#include "../reftable/reftable-basics.h"
> #include "../reftable/reftable-stack.h"
> #include "../reftable/reftable-record.h"
> #include "../reftable/reftable-error.h"
> @@ -289,7 +290,16 @@ static struct ref_store *reftable_be_init(struct repository *repo,
> refs->store_flags = store_flags;
> refs->log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo);
>
> - refs->write_options.hash_id = repo->hash_algo->format_id;
> + switch (repo->hash_algo->format_id) {
> + case GIT_SHA1_FORMAT_ID:
> + refs->write_options.hash_id = REFTABLE_HASH_SHA1;
> + break;
> + case GIT_SHA256_FORMAT_ID:
> + refs->write_options.hash_id = REFTABLE_HASH_SHA256;
> + break;
> + default:
> + BUG("unknown hash algorithm %d", repo->hash_algo->format_id);
> + }
> refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
> refs->write_options.disable_auto_compact =
> !git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1);
OK. With this step, together with the previous one, we let Git side
to use GIT_SHA{1,256}_FORMAT_ID to specify what algorithm is in use
in the repository, and reftable-backend.c layer is responsible for
translating them into REFTABLE_HASH_SHA{1,256}, which is internally
used in reftable library to convey the same thing.
Which makes sense.
> diff --git a/reftable/reftable-basics.h b/reftable/reftable-basics.h
> index 6e8e636b716..e0397ed5836 100644
> --- a/reftable/reftable-basics.h
> +++ b/reftable/reftable-basics.h
> @@ -11,6 +11,19 @@
>
> #include <stddef.h>
>
> +/*
> + * Hash functions understood by the reftable library. Note that the values are
> + * arbitrary and somewhat random such that we can easily detect cases where the
> + * hash hasn't been properly set up.
> + */
> +enum reftable_hash {
> + REFTABLE_HASH_SHA1 = 89,
> + REFTABLE_HASH_SHA256 = 247,
> +};
;-).
> +#define REFTABLE_HASH_SIZE_SHA1 20
> +#define REFTABLE_HASH_SIZE_SHA256 32
> +#define REFTABLE_HASH_SIZE_MAX REFTABLE_HASH_SIZE_SHA256
> +
> /* Overrides the functions to use for memory management. */
> void reftable_set_alloc(void *(*malloc)(size_t),
> void *(*realloc)(void *, size_t), void (*free)(void *));
OK.
next prev parent reply other threads:[~2024-11-12 5:53 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-23 9:55 [PATCH 0/7] reftable: stop using Git subsystems Patrick Steinhardt
2024-10-23 9:55 ` [PATCH 1/7] reftable/system: move "dir.h" to its only user Patrick Steinhardt
2024-10-24 4:18 ` Eric Sunshine
2024-10-23 9:55 ` [PATCH 2/7] reftable: explicitly handle hash format IDs Patrick Steinhardt
2024-11-07 23:11 ` Justin Tobler
2024-10-23 9:56 ` [PATCH 3/7] reftable/system: stop depending on "hash.h" Patrick Steinhardt
2024-11-08 1:10 ` Justin Tobler
2024-11-08 6:17 ` Patrick Steinhardt
2024-10-23 9:56 ` [PATCH 4/7] reftable/stack: stop using `fsync_component()` directly Patrick Steinhardt
2024-11-08 2:09 ` Justin Tobler
2024-11-08 6:17 ` Patrick Steinhardt
2024-10-23 9:56 ` [PATCH 5/7] reftable/system: provide thin wrapper for tempfile subsystem Patrick Steinhardt
2024-10-23 9:56 ` [PATCH 6/7] reftable/stack: drop only use of `get_locked_file_path()` Patrick Steinhardt
2024-10-23 9:56 ` [PATCH 7/7] reftable/system: provide thin wrapper for lockfile subsystem Patrick Steinhardt
2024-11-08 8:17 ` [PATCH v2 0/7] reftable: stop using Git subsystems Patrick Steinhardt
2024-11-08 8:17 ` [PATCH v2 1/7] reftable/system: move "dir.h" to its only user Patrick Steinhardt
2024-11-08 8:17 ` [PATCH v2 2/7] reftable: explicitly handle hash format IDs Patrick Steinhardt
2024-11-18 13:47 ` karthik nayak
2024-11-08 8:17 ` [PATCH v2 3/7] reftable/system: stop depending on "hash.h" Patrick Steinhardt
2024-11-12 5:53 ` Junio C Hamano [this message]
2024-11-18 13:54 ` karthik nayak
2024-11-08 8:17 ` [PATCH v2 4/7] reftable/stack: stop using `fsync_component()` directly Patrick Steinhardt
2024-11-18 14:02 ` karthik nayak
2024-11-18 15:26 ` Patrick Steinhardt
2024-11-08 8:17 ` [PATCH v2 5/7] reftable/system: provide thin wrapper for tempfile subsystem Patrick Steinhardt
2024-11-18 14:18 ` karthik nayak
2024-11-18 14:29 ` karthik nayak
2024-11-08 8:17 ` [PATCH v2 6/7] reftable/stack: drop only use of `get_locked_file_path()` Patrick Steinhardt
2024-11-08 8:17 ` [PATCH v2 7/7] reftable/system: provide thin wrapper for lockfile subsystem Patrick Steinhardt
2024-11-08 17:39 ` [PATCH v2 0/7] reftable: stop using Git subsystems Justin Tobler
2024-11-11 0:37 ` Junio C Hamano
2024-11-18 14:30 ` karthik nayak
2024-11-18 15:26 ` Patrick Steinhardt
2024-11-18 15:33 ` [PATCH v3 " Patrick Steinhardt
2024-11-18 15:33 ` [PATCH v3 1/7] reftable/system: move "dir.h" to its only user Patrick Steinhardt
2024-11-18 15:33 ` [PATCH v3 2/7] reftable: explicitly handle hash format IDs Patrick Steinhardt
2024-11-18 15:33 ` [PATCH v3 3/7] reftable/system: stop depending on "hash.h" Patrick Steinhardt
2024-11-18 15:34 ` [PATCH v3 4/7] reftable/stack: stop using `fsync_component()` directly Patrick Steinhardt
2024-11-18 15:34 ` [PATCH v3 5/7] reftable/system: provide thin wrapper for tempfile subsystem Patrick Steinhardt
2024-11-18 15:34 ` [PATCH v3 6/7] reftable/stack: drop only use of `get_locked_file_path()` Patrick Steinhardt
2024-11-18 15:34 ` [PATCH v3 7/7] reftable/system: provide thin wrapper for lockfile subsystem Patrick Steinhardt
2024-11-19 14:23 ` [PATCH v3 0/7] reftable: stop using Git subsystems karthik nayak
2024-11-20 1:09 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqh68d6lqt.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ethomson@edwardthomson.com \
--cc=git@vger.kernel.org \
--cc=jltobler@gmail.com \
--cc=ps@pks.im \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).