]> git.ipfire.org Git - thirdparty/git.git/commit
reftable: explicitly handle hash format IDs
authorPatrick Steinhardt <ps@pks.im>
Mon, 18 Nov 2024 15:33:55 +0000 (16:33 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Nov 2024 03:23:09 +0000 (12:23 +0900)
commit88e297275b94f2fbbc60b770f37654796799b907
tree66e5ab299f93ebda39bff909eb6a50976cc3fb0d
parent17e80398782b4e8746a389604aaaf9744fd6900a
reftable: explicitly handle hash format IDs

The hash format IDs are used for two different things across the
reftable codebase:

  - They are used as a 32 bit unsigned integer when reading and writing
    the header in order to identify the hash function.

  - They are used internally to identify which hash function is in use.

When one only considers the second usecase one might think that one can
easily change the representation of those hash IDs. But because those
IDs end up in the reftable header and footer on disk it is important
that those never change.

Create separate constants `REFTABLE_FORMAT_ID_*` and use them in
contexts where we read or write reftable headers. This serves multiple
purposes:

  - It allows us to more easily discern cases where we actually use
    those constants for the on-disk format.

  - It detangles us from the same constants that are defined in
    libgit.a, which is another required step to convert the reftable
    library to become standalone.

  - It makes the next step easier where we stop using `GIT_*_FORMAT_ID`
    constants in favor of a custom enum.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/basics.h
reftable/reader.c
reftable/writer.c