int write_notes_tree(struct notes_tree *t, struct object_id *result) { struct tree_write_stack root; struct write_each_note_data cb_data; int ret; int flags; if (!t) t = &default_notes_tree; assert(t->initialized); /* Prepare for traversal of current notes tree */ root.next = NULL; /* last forward entry in list is grounded */ strbuf_init(&root.buf, 256 * (32 + GIT_SHA1_HEXSZ)); /* assume 256 entries */ root.path[0] = root.path[1] = '\0'; cb_data.root = &root; cb_data.next_non_note = t->first_non_note; /* Write tree objects representing current notes tree */ flags = FOR_EACH_NOTE_DONT_UNPACK_SUBTREES | FOR_EACH_NOTE_YIELD_SUBTREES; ret = for_each_note(t, flags, write_each_note, &cb_data) || write_each_non_note_until(NULL, &cb_data) || tree_write_stack_finish_subtree(&root) || write_object_file(root.buf.buf, root.buf.len, tree_type, result); strbuf_release(&root.buf); return ret; }
static void regenerate_marks(void) { int ret; FILE *marksfile = xfopen(marksfilename, "w+"); ret = for_each_note(NULL, 0, note2mark_cb, marksfile); if (ret) die("Regeneration of marks failed, returned %d.", ret); fclose(marksfile); }
static void regenerate_marks(void) { int ret; FILE *marksfile = fopen(marksfilename, "w+"); if (!marksfile) die_errno("Couldn't create mark file %s.", marksfilename); ret = for_each_note(NULL, 0, note2mark_cb, marksfile); if (ret) die("Regeneration of marks failed, returned %d.", ret); fclose(marksfile); }
void prune_notes(struct notes_tree *t) { struct note_delete_list *l = NULL; if (!t) t = &default_notes_tree; assert(t->initialized); for_each_note(t, 0, prune_notes_helper, &l); while (l) { remove_note(t, l->sha1); l = l->next; } }
void prune_notes(struct notes_tree *t, int flags) { struct note_delete_list *l = NULL; if (!t) t = &default_notes_tree; assert(t->initialized); for_each_note(t, 0, prune_notes_helper, &l); while (l) { if (flags & NOTES_PRUNE_VERBOSE) printf("%s\n", sha1_to_hex(l->sha1)); if (!(flags & NOTES_PRUNE_DRYRUN)) remove_note(t, l->sha1); l = l->next; } }
static int list(int argc, const char **argv, const char *prefix) { struct notes_tree *t; unsigned char object[20]; const unsigned char *note; int retval = -1; struct option options[] = { OPT_END() }; if (argc) argc = parse_options(argc, argv, prefix, options, git_notes_list_usage, 0); if (1 < argc) { error("too many parameters"); usage_with_options(git_notes_list_usage, options); } t = init_notes_check("list"); if (argc) { if (get_sha1(argv[0], object)) die("Failed to resolve '%s' as a valid ref.", argv[0]); note = get_note(t, object); if (note) { puts(sha1_to_hex(note)); retval = 0; } else retval = error("No note found for object %s.", sha1_to_hex(object)); } else retval = for_each_note(t, 0, list_each_note, NULL); free_notes(t); return retval; }
static int list(int argc, const char **argv, const char *prefix) { struct notes_tree *t; struct object_id object; const struct object_id *note; int retval = -1; struct option options[] = { OPT_END() }; if (argc) argc = parse_options(argc, argv, prefix, options, git_notes_list_usage, 0); if (1 < argc) { error(_("too many parameters")); usage_with_options(git_notes_list_usage, options); } t = init_notes_check("list", 0); if (argc) { if (get_oid(argv[0], &object)) die(_("failed to resolve '%s' as a valid ref."), argv[0]); note = get_note(t, &object); if (note) { puts(oid_to_hex(note)); retval = 0; } else retval = error(_("no note found for object %s."), oid_to_hex(&object)); } else retval = for_each_note(t, 0, list_each_note, NULL); free_notes(t); return retval; }