From: Derrick Stolee <stolee@gmail.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>,
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org, martin.agren@gmail.com, me@ttaylorr.com,
abhishekkumar8222@gmail.com,
Derrick Stolee <derrickstolee@github.com>,
Derrick Stolee <dstolee@microsoft.com>
Subject: Re: [PATCH 2/3] commit-graph: use the hash version byte
Date: Fri, 14 Aug 2020 16:36:42 -0400 [thread overview]
Message-ID: <7082f3c9-652e-36d9-26ae-d1f86e872480@gmail.com> (raw)
In-Reply-To: <20200814201153.GK8085@camp.crustytoothpaste.net>
On 8/14/2020 4:11 PM, brian m. carlson wrote:
> On 2020-08-14 at 18:07:19, Derrick Stolee via GitGitGadget wrote:
>> diff --git a/commit-graph.c b/commit-graph.c
>> index e51c91dd5b..d03328d64c 100644
>> --- a/commit-graph.c
>> +++ b/commit-graph.c
>> @@ -179,7 +179,11 @@ static char *get_chain_filename(struct object_directory *odb)
>>
>> static uint8_t oid_version(void)
>> {
>> - return 1;
>> + if (the_hash_algo->rawsz == GIT_SHA1_RAWSZ)
>> + return 1;
>> + if (the_hash_algo->rawsz == GIT_SHA256_RAWSZ)
>> + return 2;
>> + die(_("invalid hash version"));
>> }
>
> Can we maybe say something like this?
>
> switch (hash_algo_by_ptr(the_hash_algo)) {
> case GIT_HASH_SHA1:
> return 1;
> case GIT_HASH_SHA256:
> return 2;
> default:
> die(_("invalid hash version"));
> }
>
> That way if SHA-256 gets broken and we switch to another 256-bit hash
> (SHA-3-256?), we'll be forced to update this properly.
>
>> static struct commit_graph *alloc_commit_graph(void)
>> diff --git a/t/t4216-log-bloom.sh b/t/t4216-log-bloom.sh
>> index c21cc160f3..906af2799d 100755
>> --- a/t/t4216-log-bloom.sh
>> +++ b/t/t4216-log-bloom.sh
>> @@ -6,6 +6,12 @@ test_description='git log for a path with Bloom filters'
>> GIT_TEST_COMMIT_GRAPH=0
>> GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0
>>
>> +OID_VERSION=1
>> +if [ "$GIT_DEFAULT_HASH" = "sha256" ]
>> +then
>> + OID_VERSION=2
>> +fi
>
> Can we do something like this in the setup test instead?
>
> test_oid_cache <<-EOF
> oid_version sha1:1
> oid_version sha256:2
> EOF
>
> OID_VERSION=$(test_oid oid_version)
> # or, inline
> $(test_oid oid_version)
>
> That uses the existing test framework to ensure we produce the right
> results if someone adds another hash algorithm and that we produce a BUG
> if the value is missing. It will also make it easier to write tests if
> we end up creating SHA-1- or SHA-256-specific tests, since we can look
> up those values directly with test_oid.
>
> Since you're using this across several tests, you could even just add
> this to t/oid-info/hash-info like so:
>
> commit_graph_oid_version sha1:1
> commit_graph_oid_version sha256:2
>
> and then it's set in one place and can be used without any required
> test_oid_cache invocations at all. I think three tests is sufficient
> basis for us to add an entry there.
I appreciate the suggested improvements here. I'm happy to do
something more similar to other places in the code.
These will be part of my v2 to be re-rolled early next week.
Thanks,
-Stolee
next prev parent reply other threads:[~2020-08-14 20:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-14 18:07 [PATCH 0/3] SHA-256: Update commit-graph and multi-pack-index formats Derrick Stolee via GitGitGadget
2020-08-14 18:07 ` [PATCH 1/3] t/README: document GIT_TEST_DEFAULT_HASH Derrick Stolee via GitGitGadget
2020-08-14 19:02 ` Junio C Hamano
2020-08-14 20:39 ` Eric Sunshine
2020-08-14 20:41 ` Derrick Stolee
2020-08-14 18:07 ` [PATCH 2/3] commit-graph: use the hash version byte Derrick Stolee via GitGitGadget
2020-08-14 19:05 ` Junio C Hamano
2020-08-14 20:05 ` Taylor Blau
2020-08-14 20:11 ` brian m. carlson
2020-08-14 20:22 ` Junio C Hamano
2020-08-14 20:36 ` Derrick Stolee [this message]
2020-08-15 13:46 ` Martin Ågren
2020-08-14 18:07 ` [PATCH 3/3] multi-pack-index: use " Derrick Stolee via GitGitGadget
2020-08-14 20:14 ` brian m. carlson
2020-08-14 19:25 ` [PATCH 0/3] SHA-256: Update commit-graph and multi-pack-index formats Junio C Hamano
2020-08-14 20:34 ` Derrick Stolee
2020-08-14 21:41 ` Junio C Hamano
2020-08-17 14:04 ` [PATCH v2 " Derrick Stolee via GitGitGadget
2020-08-17 14:04 ` [PATCH v2 1/3] t/README: document GIT_TEST_DEFAULT_HASH Derrick Stolee via GitGitGadget
2020-08-17 14:04 ` [PATCH v2 2/3] commit-graph: use the "hash version" byte Derrick Stolee via GitGitGadget
2020-08-17 14:04 ` [PATCH v2 3/3] multi-pack-index: use hash version byte Derrick Stolee via GitGitGadget
2020-08-17 23:12 ` [PATCH v2 0/3] SHA-256: Update commit-graph and multi-pack-index formats brian m. carlson
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7082f3c9-652e-36d9-26ae-d1f86e872480@gmail.com \
--to=stolee@gmail.com \
--cc=abhishekkumar8222@gmail.com \
--cc=derrickstolee@github.com \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=martin.agren@gmail.com \
--cc=me@ttaylorr.com \
--cc=sandals@crustytoothpaste.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).