From: brian m. carlson Date: Wed, 29 Aug 2018 00:58:57 GMT Subject: [RFC PATCH 12/12] commit-graph: specify OID version for SHA-256 Message-ID: <20180829005857.980820-13-sandals@crustytoothpaste.net> In-Reply-To: <20180829005857.980820-1-sandals@crustytoothpaste.net> Since the commit-graph code wants to serialize the hash algorithm into the data store, specify a version number for each supported algorithm. Note that we don't use the values of the constants themselves, as they are internal and could change in the future. Signed-off-by: brian m. carlson --- commit-graph.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/commit-graph.c b/commit-graph.c index 29356d84a2..5b86acdb43 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -45,7 +45,14 @@ char *get_commit_graph_filename(const char *obj_dir) static uint8_t oid_version(void) { - return 1; + switch (hash_algo_by_ptr(the_hash_algo)) { + case GIT_HASH_SHA1: + return 1; + case GIT_HASH_SHA256: + return 2; + default: + BUG("unknown hash algorithm"); + } } static struct commit_graph *alloc_commit_graph(void)