pack-bitmap: replace sha1_to_hex
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Feb 19, 2019 at 00:04 UTC
0dd4924891664e9e9970e427e84f902491fcd3d3
2 files changed
+7
-7
pack-bitmap-write.c
+3
-3
@@ -142,13 +142,13 @@ static inline void reset_all_seen(void)
142
seen_objects_nr = 0;
143
}
144
145
-static uint32_t find_object_pos(const unsigned char *sha1)
145
+static uint32_t find_object_pos(const unsigned char *hash)
146
{
147
- struct object_entry *entry = packlist_find(writer.to_pack, sha1, NULL);
147
+ struct object_entry *entry = packlist_find(writer.to_pack, hash, NULL);
148
149
if (!entry) {
150
die("Failed to write bitmap index. Packfile doesn't have full closure "
151
- "(object %s is missing)", sha1_to_hex(sha1));
151
+ "(object %s is missing)", hash_to_hex(hash));
152
}
153
154
return oe_in_pack_pos(writer.to_pack, entry);
pack-bitmap.c
+4
-4
@@ -169,7 +169,7 @@ static int load_bitmap_header(struct bitmap_index *index)
169
170
static struct stored_bitmap *store_bitmap(struct bitmap_index *index,
171
struct ewah_bitmap *root,
172
- const unsigned char *sha1,
172
+ const unsigned char *hash,
173
struct stored_bitmap *xor_with,
174
int flags)
175
{
@@ -181,7 +181,7 @@ static struct stored_bitmap *store_bitmap(struct bitmap_index *index,
181
stored->root = root;
182
stored->xor = xor_with;
183
stored->flags = flags;
184
- oidread(&stored->oid, sha1);
184
+ oidread(&stored->oid, hash);
185
186
hash_pos = kh_put_sha1(index->bitmaps, stored->oid.hash, &ret);
187
@@ -189,7 +189,7 @@ static struct stored_bitmap *store_bitmap(struct bitmap_index *index,
189
* because the SHA1 already existed on the map. this is bad, there
190
* shouldn't be duplicated commits in the index */
191
if (ret == 0) {
192
- error("Duplicate entry in bitmap index: %s", sha1_to_hex(sha1));
192
+ error("Duplicate entry in bitmap index: %s", hash_to_hex(hash));
193
return NULL;
194
}
195
@@ -805,7 +805,7 @@ int reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
805
806
fprintf(stderr, "Failed to reuse at %d (%016llx)\n",
807
reuse_objects, result->words[i]);
808
- fprintf(stderr, " %s\n", sha1_to_hex(sha1));
808
+ fprintf(stderr, " %s\n", hash_to_hex(sha1));
809
}
810
#endif
811