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

[PATCH v2 05/35] pack-bitmap: replace sha1_to_hex

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Feb 19, 2019, 00:04 UTC
Message-ID
<20190219000526.476553-6-sandals@crustytoothpaste.net>
In-Reply-To
<20190219000526.476553-1-sandals@crustytoothpaste.net>

Replace the uses of sha1_to_hex in the pack bitmap code with hash_to_hex to allow the use of SHA-256 as well. Rename a few variables since they are no longer limited to SHA-1.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 pack-bitmap-write.c | 6 +++---
 pack-bitmap.c       | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index c82fb01fd7..802ed62677 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -142,13 +142,13 @@ static inline void reset_all_seen(void)
 	seen_objects_nr = 0;
 }
 
-static uint32_t find_object_pos(const unsigned char *sha1)
+static uint32_t find_object_pos(const unsigned char *hash)
 {
-	struct object_entry *entry = packlist_find(writer.to_pack, sha1, NULL);
+	struct object_entry *entry = packlist_find(writer.to_pack, hash, NULL);
 
 	if (!entry) {
 		die("Failed to write bitmap index. Packfile doesn't have full closure "
-			"(object %s is missing)", sha1_to_hex(sha1));
+			"(object %s is missing)", hash_to_hex(hash));
 	}
 
 	return oe_in_pack_pos(writer.to_pack, entry);
diff --git a/pack-bitmap.c b/pack-bitmap.c
index c760913cea..6d6fa68563 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -169,7 +169,7 @@ static int load_bitmap_header(struct bitmap_index *index)
 
 static struct stored_bitmap *store_bitmap(struct bitmap_index *index,
 					  struct ewah_bitmap *root,
-					  const unsigned char *sha1,
+					  const unsigned char *hash,
 					  struct stored_bitmap *xor_with,
 					  int flags)
 {
@@ -181,7 +181,7 @@ static struct stored_bitmap *store_bitmap(struct bitmap_index *index,
 	stored->root = root;
 	stored->xor = xor_with;
 	stored->flags = flags;
-	oidread(&stored->oid, sha1);
+	oidread(&stored->oid, hash);
 
 	hash_pos = kh_put_sha1(index->bitmaps, stored->oid.hash, &ret);
 
@@ -189,7 +189,7 @@ static struct stored_bitmap *store_bitmap(struct bitmap_index *index,
 	 * because the SHA1 already existed on the map. this is bad, there
 	 * shouldn't be duplicated commits in the index */
 	if (ret == 0) {
-		error("Duplicate entry in bitmap index: %s", sha1_to_hex(sha1));
+		error("Duplicate entry in bitmap index: %s", hash_to_hex(hash));
 		return NULL;
 	}
 
@@ -805,7 +805,7 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
 
 		fprintf(stderr, "Failed to reuse at %d (%016llx)\n",
 			reuse_objects, result->words[i]);
-		fprintf(stderr, " %s\n", sha1_to_hex(sha1));
+		fprintf(stderr, " %s\n", hash_to_hex(sha1));
 	}
 #endif
 
Previous: brian m. carlsonNext: brian m. carlson
Message 6 of 36 in “Hash function transition part 16”
  1. 00/35 Hash function transition part 16brian m. carlson, Feb 19, 2019
  2. 01/35 t/lib-submodule-update: use appropriate length constantbrian m. carlson, Feb 19, 2019
  3. 02/35 khash: move oid hash table definitionbrian m. carlson, Feb 19, 2019
  4. 03/35 pack-bitmap: make bitmap header handling hash agnosticbrian m. carlson, Feb 19, 2019
  5. 06/35 pack-bitmap: switch hard-coded constants to the_hash_algobrian m. carlson, Feb 19, 2019
  6. 05/35 pack-bitmap: replace sha1_to_hexbrian m. carlson, Feb 19, 2019
  7. 07/35 pack-bitmap: switch hash tables to use struct object_idbrian m. carlson, Feb 19, 2019
  8. 09/35 notes-merge: switch to use the_hash_algobrian m. carlson, Feb 19, 2019
  9. 08/35 submodule: avoid hard-coded constantsbrian m. carlson, Feb 19, 2019
  10. 11/35 notes: replace sha1_to_hexbrian m. carlson, Feb 19, 2019
  11. 14/35 fast-import: make hash-size independentbrian m. carlson, Feb 19, 2019
  12. 17/35 builtin/pull: make hash-size independentbrian m. carlson, Feb 19, 2019
  13. 15/35 fast-import: replace sha1_to_hexbrian m. carlson, Feb 19, 2019
  14. 12/35 object-store: rename and expand packed_git's sha1 memberbrian m. carlson, Feb 19, 2019
  15. 19/35 http-backend: allow 64-character hex namesbrian m. carlson, Feb 19, 2019
  16. 18/35 http-push: convert to use the_hash_algobrian m. carlson, Feb 19, 2019
  17. 21/35 http-walker: replace sha1_to_hexbrian m. carlson, Feb 19, 2019
  18. 22/35 http: replace hard-coded constant with the_hash_algobrian m. carlson, Feb 19, 2019
  19. 20/35 http-push: remove remaining uses of sha1_to_hexbrian m. carlson, Feb 19, 2019
  20. 23/35 http: compute hash of downloaded objects using the_hash_algobrian m. carlson, Feb 19, 2019
  21. 24/35 http: replace sha1_to_hexbrian m. carlson, Feb 19, 2019
  22. 25/35 remote-curl: make hash size independentbrian m. carlson, Feb 19, 2019
  23. 26/35 hash: add a function to lookup hash algorithm by lengthbrian m. carlson, Feb 19, 2019
  24. 30/35 refspec: make hash size independentbrian m. carlson, Feb 19, 2019
  25. 27/35 get-tar-commit-id: parse comment recordbrian m. carlson, Feb 19, 2019
  26. 29/35 archive: convert struct archiver_args to object_idbrian m. carlson, Feb 19, 2019
  27. 34/35 Git.pm: make hash size independentbrian m. carlson, Feb 19, 2019
  28. 33/35 read-cache: read data in a hash-independent waybrian m. carlson, Feb 19, 2019
  29. 31/35 builtin/difftool: use parse_oid_hexbrian m. carlson, Feb 19, 2019
  30. 35/35 gitweb: make hash size independentbrian m. carlson, Feb 19, 2019
  31. 32/35 dir: make untracked cache extension hash size independentbrian m. carlson, Feb 19, 2019
  32. 16/35 builtin/am: make hash size independentbrian m. carlson, Feb 19, 2019
  33. 28/35 builtin/get-tar-commit-id: make hash size independentbrian m. carlson, Feb 19, 2019
  34. 13/35 builtin/name-rev: make hash-size independentbrian m. carlson, Feb 19, 2019
  35. 04/35 pack-bitmap: convert struct stored_bitmap to object_idbrian m. carlson, Feb 19, 2019
  36. 10/35 notes: make hash size independentbrian m. carlson, Feb 19, 2019

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.