]> git.ipfire.org Git - thirdparty/git.git/blobdiff - notes.c
hash: set, copy, and use algo field in struct object_id
[thirdparty/git.git] / notes.c
diff --git a/notes.c b/notes.c
index d5ac081e76df9cd03edd273177a15e42aa25d407..135ea13ba142ee657795e27f7e1db6e4d697eecf 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -352,7 +352,7 @@ static void add_non_note(struct notes_tree *t, char *path,
        n->next = NULL;
        n->path = path;
        n->mode = mode;
-       hashcpy(n->oid.hash, sha1);
+       oidread(&n->oid, sha1);
        t->prev_non_note = n;
 
        if (!t->first_non_note) {
@@ -452,9 +452,11 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
                        goto handle_non_note;
                }
 
-               l = xcalloc(1, sizeof(*l));
+               CALLOC_ARRAY(l, 1);
                oidcpy(&l->key_oid, &object_oid);
                oidcpy(&l->val_oid, &entry.oid);
+               oid_set_algo(&l->key_oid, the_hash_algo);
+               oid_set_algo(&l->val_oid, the_hash_algo);
                if (note_tree_insert(t, node, n, l, type,
                                     combine_notes_concatenate))
                        die("Failed to load %s %s into notes tree "
@@ -484,6 +486,7 @@ handle_non_note:
                                strbuf_addch(&non_note_path, '/');
                        }
                        strbuf_addstr(&non_note_path, entry.path);
+                       oid_set_algo(&entry.oid, the_hash_algo);
                        add_non_note(t, strbuf_detach(&non_note_path, NULL),
                                     entry.mode, entry.oid.hash);
                }
@@ -1134,7 +1137,7 @@ int remove_note(struct notes_tree *t, const unsigned char *object_sha1)
        if (!t)
                t = &default_notes_tree;
        assert(t->initialized);
-       hashcpy(l.key_oid.hash, object_sha1);
+       oidread(&l.key_oid, object_sha1);
        oidclr(&l.val_oid);
        note_tree_remove(t, t->root, 0, &l);
        if (is_null_oid(&l.val_oid)) /* no note was removed */