]> git.ipfire.org Git - thirdparty/git.git/commit - t/t5318-commit-graph.sh
commit-graph: use the "hash version" byte
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 17 Aug 2020 14:04:47 +0000 (14:04 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Aug 2020 23:45:14 +0000 (16:45 -0700)
commit665d70ad033b115d8c14cdc2bcecf6c8b1947260
tree17aa7445a44722996df856cf93c57a87019c3846
parentf3d66ec87153f6b0e4ef081f56f283ac046617ad
commit-graph: use the "hash version" byte

The commit-graph format reserved a byte among the header of the file to
store a "hash version". During the SHA-256 work, this was not modified
because file formats are not necessarily intended to work across hash
versions. If a repository has SHA-256 as its hash algorithm, it
automatically up-shifts the lengths of object names in all necessary
formats.

However, since we have this byte available for adjusting the version, we
can make the file formats more obviously incompatible instead of relying
on other context from the repository.

Update the oid_version() method in commit-graph.c to add a new value, 2,
for sha-256. This automatically writes the new value in a SHA-256
repository _and_ verifies the value is correct. This is a breaking
change relative to the current 'master' branch since 092b677 (Merge
branch 'bc/sha-256-cvs-svn-updates', 2020-08-13) but it is not breaking
relative to any released version of Git.

The test impact is relatively minor: the output of 'test-tool
read-graph' lists the header information, so those instances of '1' need
to be replaced with a variable determined by GIT_TEST_DEFAULT_HASH. A
more careful test is added that specifically creates a repository of
each type then swaps the commit-graph files. The important value here is
that the "git log" command succeeds while writing a message to stderr.

Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/technical/commit-graph-format.txt
commit-graph.c
t/t4216-log-bloom.sh
t/t5318-commit-graph.sh
t/t5324-split-commit-graph.sh