summaryrefslogtreecommitdiff
path: root/notes.c
diff options
context:
space:
mode:
authorLibravatar brian m. carlson <sandals@crustytoothpaste.net>2019-02-19 00:05:02 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-04-01 11:57:38 +0900
commit0dbc6462ee8853da1ecca7b50cd0c0c9bc62e25b (patch)
tree5e01b873942084e5619db1e8ae7e3d733e9854ff /notes.c
parentnotes: make hash size independent (diff)
downloadtgif-0dbc6462ee8853da1ecca7b50cd0c0c9bc62e25b.tar.xz
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>
Diffstat (limited to 'notes.c')
-rw-r--r--notes.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/notes.c b/notes.c
index 5457bd70c6..be72780a8f 100644
--- a/notes.c
+++ b/notes.c
@@ -532,19 +532,19 @@ static unsigned char determine_fanout(struct int_node *tree, unsigned char n,
/* hex oid + '/' between each pair of hex digits + NUL */
#define FANOUT_PATH_MAX GIT_MAX_HEXSZ + FANOUT_PATH_SEPARATORS_MAX + 1
-static void construct_path_with_fanout(const unsigned char *sha1,
+static void construct_path_with_fanout(const unsigned char *hash,
unsigned char fanout, char *path)
{
unsigned int i = 0, j = 0;
- const char *hex_sha1 = sha1_to_hex(sha1);
+ const char *hex_hash = hash_to_hex(hash);
assert(fanout < the_hash_algo->rawsz);
while (fanout) {
- path[i++] = hex_sha1[j++];
- path[i++] = hex_sha1[j++];
+ path[i++] = hex_hash[j++];
+ path[i++] = hex_hash[j++];
path[i++] = '/';
fanout--;
}
- xsnprintf(path + i, FANOUT_PATH_MAX - i, "%s", hex_sha1 + j);
+ xsnprintf(path + i, FANOUT_PATH_MAX - i, "%s", hex_hash + j);
}
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)
while (l) {
if (flags & NOTES_PRUNE_VERBOSE)
- printf("%s\n", sha1_to_hex(l->sha1));
+ printf("%s\n", hash_to_hex(l->sha1));
if (!(flags & NOTES_PRUNE_DRYRUN))
remove_note(t, l->sha1);
l = l->next;