notes: replace sha1_to_hex
Replace the uses of sha1_to_hex in this function with hash_to_hex to allow the use of SHA-256 as well. Rename some variables since this code is 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:05 UTC
0dbc6462ee8853da1ecca7b50cd0c0c9bc62e25b
1 file changed
+6
-6
notes.c
+6
-6
@@ -532,19 +532,19 @@ static unsigned char determine_fanout(struct int_node *tree, unsigned char n,
532
/* hex oid + '/' between each pair of hex digits + NUL */
533
#define FANOUT_PATH_MAX GIT_MAX_HEXSZ + FANOUT_PATH_SEPARATORS_MAX + 1
534
535
-static void construct_path_with_fanout(const unsigned char *sha1,
535
+static void construct_path_with_fanout(const unsigned char *hash,
536
unsigned char fanout, char *path)
537
{
538
unsigned int i = 0, j = 0;
539
- const char *hex_sha1 = sha1_to_hex(sha1);
539
+ const char *hex_hash = hash_to_hex(hash);
540
assert(fanout < the_hash_algo->rawsz);
541
while (fanout) {
542
- path[i++] = hex_sha1[j++];
543
- path[i++] = hex_sha1[j++];
542
+ path[i++] = hex_hash[j++];
543
+ path[i++] = hex_hash[j++];
544
path[i++] = '/';
545
fanout--;
546
}
547
- xsnprintf(path + i, FANOUT_PATH_MAX - i, "%s", hex_sha1 + j);
547
+ xsnprintf(path + i, FANOUT_PATH_MAX - i, "%s", hex_hash + j);
548
}
549
550
static int for_each_note_helper(struct notes_tree *t, struct int_node *tree,
@@ -1167,7 +1167,7 @@ void prune_notes(struct notes_tree *t, int flags)
1167
1168
while (l) {
1169
if (flags & NOTES_PRUNE_VERBOSE)
1170
- printf("%s\n", sha1_to_hex(l->sha1));
1170
+ printf("%s\n", hash_to_hex(l->sha1));
1171
if (!(flags & NOTES_PRUNE_DRYRUN))
1172
remove_note(t, l->sha1);
1173
l = l->next;