MCPcopy Index your code
hub / github.com/git/git / init_notes

Function init_notes

notes.c:1015–1058  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1013}
1014
1015void init_notes(struct notes_tree *t, const char *notes_ref,
1016 combine_notes_fn combine_notes, int flags)
1017{
1018 struct object_id oid, object_oid;
1019 unsigned short mode;
1020 struct leaf_node root_tree;
1021 char *to_free = NULL;
1022
1023 if (!t)
1024 t = &default_notes_tree;
1025 assert(!t->initialized);
1026
1027 if (!notes_ref)
1028 notes_ref = to_free = default_notes_ref(the_repository);
1029 update_ref_namespace(NAMESPACE_NOTES, xstrdup(notes_ref));
1030
1031 if (!combine_notes)
1032 combine_notes = combine_notes_concatenate;
1033
1034 t->root = (struct int_node *) xcalloc(1, sizeof(struct int_node));
1035 t->first_non_note = NULL;
1036 t->prev_non_note = NULL;
1037 t->ref = xstrdup(notes_ref);
1038 t->update_ref = (flags & NOTES_INIT_WRITABLE) ? t->ref : NULL;
1039 t->combine_notes = combine_notes;
1040 t->initialized = 1;
1041 t->dirty = 0;
1042
1043 if (flags & NOTES_INIT_EMPTY ||
1044 repo_get_oid_treeish(the_repository, notes_ref, &object_oid))
1045 goto out;
1046 if (flags & NOTES_INIT_WRITABLE && refs_read_ref(get_main_ref_store(the_repository), notes_ref, &object_oid))
1047 die("Cannot use notes ref %s", notes_ref);
1048 if (get_tree_entry(the_repository, &object_oid, "", &oid, &mode))
1049 die("Failed to read notes tree referenced by %s (%s)",
1050 notes_ref, oid_to_hex(&object_oid));
1051
1052 oidclr(&root_tree.key_oid, the_repository->hash_algo);
1053 oidcpy(&root_tree.val_oid, &oid);
1054 load_subtree(t, &root_tree, t->root, 0);
1055
1056out:
1057 free(to_free);
1058}
1059
1060struct notes_tree **load_notes_trees(struct string_list *refs, int flags)
1061{

Callers 6

load_notes_treesFunction · 0.85
format_noteFunction · 0.85
notes_cache_initFunction · 0.85
notes_copy_from_stdinFunction · 0.85
init_notes_checkFunction · 0.85
merge_commitFunction · 0.85

Calls 13

default_notes_refFunction · 0.85
update_ref_namespaceFunction · 0.85
xstrdupFunction · 0.85
xcallocFunction · 0.85
repo_get_oid_treeishFunction · 0.85
refs_read_refFunction · 0.85
get_main_ref_storeFunction · 0.85
get_tree_entryFunction · 0.85
oid_to_hexFunction · 0.85
oidclrFunction · 0.85
oidcpyFunction · 0.85
load_subtreeFunction · 0.85

Tested by

no test coverage detected