git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH 12/12] commit-graph: specify OID version for SHA-256

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Aug 29, 2018, 00:58 UTC
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 <sandals@crustytoothpaste.net>
---
 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)
Previous: brian m. carlsonNext: brian m. carlson
Message 20 of 24 in “Base SHA-256 algorithm implementation”
  1. 00/12 Base SHA-256 algorithm implementationbrian m. carlson, Aug 29, 2018
  2. 01/12 sha1-file: rename algorithm to "sha1"brian m. carlson, Aug 29, 2018
  3. 03/12 hex: introduce functions to print arbitrary hashesbrian m. carlson, Aug 29, 2018
  4. 04/12 t: add basic tests for our SHA-1 implementationbrian m. carlson, Aug 29, 2018
  5. 05/12 t: make the sha1 test-tool helper genericbrian m. carlson, Aug 29, 2018
  6. 07/12 t/helper: add a test helper to compute hash speedbrian m. carlson, Aug 29, 2018
  7. 06/12 sha1-file: add a constant for hash block sizebrian m. carlson, Aug 29, 2018
  8. 08/12 commit-graph: convert to using the_hash_algobrian m. carlson, Aug 29, 2018
  9. Derrick StoleeAug 29, 2018
  10. brian m. carlsonAug 30, 2018
  11. brian m. carlsonSep 3, 2018
  12. 09/12 Add a base implementation of SHA-256 supportbrian m. carlson, Aug 29, 2018
  13. Ævar Arnfjörð BjarmasonAug 29, 2018
  14. brian m. carlsonAug 29, 2018
  15. Derrick StoleeAug 29, 2018
  16. 10/12 sha256: add an SHA-256 implementation using libgcryptbrian m. carlson, Aug 29, 2018
  17. Ævar Arnfjörð BjarmasonAug 29, 2018
  18. brian m. carlsonAug 29, 2018
  19. 11/12 hash: add an SHA-256 implementation using OpenSSLbrian m. carlson, Aug 29, 2018
  20. 12/12 commit-graph: specify OID version for SHA-256brian m. carlson, Aug 29, 2018
  21. 02/12 sha1-file: provide functions to look up hash algorithmsbrian m. carlson, Aug 29, 2018
  22. Ævar Arnfjörð BjarmasonAug 29, 2018
  23. brian m. carlsonAug 30, 2018
  24. brian m. carlsonAug 30, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.