wildmatch: remove unused wildopts parameter
[gitweb.git] / notes.c
diff --git a/notes.c b/notes.c
index babe0c0ebf3c07cda2230bd6799e843788501029..4b3a1adda566bdc82ba7005083f37dff5bd62ed4 100644 (file)
--- a/notes.c
+++ b/notes.c
@@ -610,7 +610,7 @@ static int for_each_note_helper(struct notes_tree *t, struct int_node *tree,
                                if (path[path_len - 1] != '/')
                                        path[path_len++] = '/';
                                path[path_len] = '\0';
-                               ret = fn(l->key_oid.hash, l->val_oid.hash,
+                               ret = fn(&l->key_oid, &l->val_oid,
                                         path,
                                         cb_data);
                        }
@@ -627,7 +627,7 @@ static int for_each_note_helper(struct notes_tree *t, struct int_node *tree,
                        l = (struct leaf_node *) CLR_PTR_TYPE(p);
                        construct_path_with_fanout(l->key_oid.hash, fanout,
                                                   path);
-                       ret = fn(l->key_oid.hash, l->val_oid.hash, path,
+                       ret = fn(&l->key_oid, &l->val_oid, path,
                                 cb_data);
                        break;
                }
@@ -698,7 +698,7 @@ static int tree_write_stack_finish_subtree(struct tree_write_stack *tws)
 
 static int write_each_note_helper(struct tree_write_stack *tws,
                const char *path, unsigned int mode,
-               const unsigned char *sha1)
+               const struct object_id *oid)
 {
        size_t path_len = strlen(path);
        unsigned int n = 0;
@@ -728,7 +728,7 @@ static int write_each_note_helper(struct tree_write_stack *tws,
 
        /* Finally add given entry to the current tree object */
        write_tree_entry(&tws->buf, mode, path + 3 * n, path_len - (3 * n),
-                        sha1);
+                        oid->hash);
 
        return 0;
 }
@@ -748,7 +748,7 @@ static int write_each_non_note_until(const char *note_path,
                        ; /* do nothing, prefer note to non-note */
                else {
                        ret = write_each_note_helper(d->root, n->path, n->mode,
-                                                    n->oid.hash);
+                                                    &n->oid);
                        if (ret)
                                return ret;
                }
@@ -758,8 +758,8 @@ static int write_each_non_note_until(const char *note_path,
        return 0;
 }
 
-static int write_each_note(const unsigned char *object_sha1,
-               const unsigned char *note_sha1, char *note_path,
+static int write_each_note(const struct object_id *object_oid,
+               const struct object_id *note_oid, char *note_path,
                void *cb_data)
 {
        struct write_each_note_data *d =
@@ -777,7 +777,7 @@ static int write_each_note(const unsigned char *object_sha1,
 
        /* Weave non-note entries into note entries */
        return  write_each_non_note_until(note_path, d) ||
-               write_each_note_helper(d->root, note_path, mode, note_sha1);
+               write_each_note_helper(d->root, note_path, mode, note_oid);
 }
 
 struct note_delete_list {
@@ -785,20 +785,20 @@ struct note_delete_list {
        const unsigned char *sha1;
 };
 
-static int prune_notes_helper(const unsigned char *object_sha1,
-               const unsigned char *note_sha1, char *note_path,
+static int prune_notes_helper(const struct object_id *object_oid,
+               const struct object_id *note_oid, char *note_path,
                void *cb_data)
 {
        struct note_delete_list **l = (struct note_delete_list **) cb_data;
        struct note_delete_list *n;
 
-       if (has_sha1_file(object_sha1))
+       if (has_object_file(object_oid))
                return 0; /* nothing to do for this note */
 
        /* failed to find object => prune this note */
        n = (struct note_delete_list *) xmalloc(sizeof(*n));
        n->next = *l;
-       n->sha1 = object_sha1;
+       n->sha1 = object_oid->hash;
        *l = n;
        return 0;
 }
@@ -1086,8 +1086,8 @@ void init_display_notes(struct display_notes_opt *opt)
        string_list_clear(&display_notes_refs, 0);
 }
 
-int add_note(struct notes_tree *t, const unsigned char *object_sha1,
-               const unsigned char *note_sha1, combine_notes_fn combine_notes)
+int add_note(struct notes_tree *t, const struct object_id *object_oid,
+               const struct object_id *note_oid, combine_notes_fn combine_notes)
 {
        struct leaf_node *l;
 
@@ -1098,8 +1098,8 @@ int add_note(struct notes_tree *t, const unsigned char *object_sha1,
        if (!combine_notes)
                combine_notes = t->combine_notes;
        l = (struct leaf_node *) xmalloc(sizeof(struct leaf_node));
-       hashcpy(l->key_oid.hash, object_sha1);
-       hashcpy(l->val_oid.hash, note_sha1);
+       oidcpy(&l->key_oid, object_oid);
+       oidcpy(&l->val_oid, note_oid);
        return note_tree_insert(t, t->root, 0, l, PTR_TYPE_NOTE, combine_notes);
 }
 
@@ -1119,16 +1119,16 @@ int remove_note(struct notes_tree *t, const unsigned char *object_sha1)
        return 0;
 }
 
-const unsigned char *get_note(struct notes_tree *t,
-               const unsigned char *object_sha1)
+const struct object_id *get_note(struct notes_tree *t,
+               const struct object_id *oid)
 {
        struct leaf_node *found;
 
        if (!t)
                t = &default_notes_tree;
        assert(t->initialized);
-       found = note_tree_find(t, t->root, 0, object_sha1);
-       return found ? found->val_oid.hash : NULL;
+       found = note_tree_find(t, t->root, 0, oid->hash);
+       return found ? &found->val_oid : NULL;
 }
 
 int for_each_note(struct notes_tree *t, int flags, each_note_fn fn,
@@ -1215,11 +1215,11 @@ void free_notes(struct notes_tree *t)
  * (raw != 0) gives the %N userformat; otherwise, the note message is given
  * for human consumption.
  */
-static void format_note(struct notes_tree *t, const unsigned char *object_sha1,
+static void format_note(struct notes_tree *t, const struct object_id *object_oid,
                        struct strbuf *sb, const char *output_encoding, int raw)
 {
        static const char utf8[] = "utf-8";
-       const unsigned char *sha1;
+       const struct object_id *oid;
        char *msg, *msg_p;
        unsigned long linelen, msglen;
        enum object_type type;
@@ -1229,11 +1229,11 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1,
        if (!t->initialized)
                init_notes(t, NULL, NULL, 0);
 
-       sha1 = get_note(t, object_sha1);
-       if (!sha1)
+       oid = get_note(t, object_oid);
+       if (!oid)
                return;
 
-       if (!(msg = read_sha1_file(sha1, &type, &msglen)) || type != OBJ_BLOB) {
+       if (!(msg = read_sha1_file(oid->hash, &type, &msglen)) || type != OBJ_BLOB) {
                free(msg);
                return;
        }
@@ -1277,22 +1277,22 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1,
        free(msg);
 }
 
-void format_display_notes(const unsigned char *object_sha1,
+void format_display_notes(const struct object_id *object_oid,
                          struct strbuf *sb, const char *output_encoding, int raw)
 {
        int i;
        assert(display_notes_trees);
        for (i = 0; display_notes_trees[i]; i++)
-               format_note(display_notes_trees[i], object_sha1, sb,
+               format_note(display_notes_trees[i], object_oid, sb,
                            output_encoding, raw);
 }
 
 int copy_note(struct notes_tree *t,
-             const unsigned char *from_obj, const unsigned char *to_obj,
+             const struct object_id *from_obj, const struct object_id *to_obj,
              int force, combine_notes_fn combine_notes)
 {
-       const unsigned char *note = get_note(t, from_obj);
-       const unsigned char *existing_note = get_note(t, to_obj);
+       const struct object_id *note = get_note(t, from_obj);
+       const struct object_id *existing_note = get_note(t, to_obj);
 
        if (!force && existing_note)
                return 1;
@@ -1300,7 +1300,7 @@ int copy_note(struct notes_tree *t,
        if (note)
                return add_note(t, to_obj, note, combine_notes);
        else if (existing_note)
-               return add_note(t, to_obj, null_sha1, combine_notes);
+               return add_note(t, to_obj, &null_oid, combine_notes);
 
        return 0;
 }