diff options
Diffstat (limited to 'notes.c')
-rw-r--r-- | notes.c | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -303,7 +303,7 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree, free(entry); return 0; } - new_node = (struct int_node *) xcalloc(sizeof(struct int_node), 1); + new_node = (struct int_node *) xcalloc(1, sizeof(struct int_node)); ret = note_tree_insert(t, new_node, n + 1, l, GET_PTR_TYPE(*p), combine_notes); if (ret) @@ -443,7 +443,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree, if (len <= 20) { type = PTR_TYPE_NOTE; l = (struct leaf_node *) - xcalloc(sizeof(struct leaf_node), 1); + xcalloc(1, sizeof(struct leaf_node)); hashcpy(l->key_sha1, object_sha1); hashcpy(l->val_sha1, entry.sha1); if (len < 20) { @@ -902,7 +902,7 @@ int combine_notes_cat_sort_uniq(unsigned char *cur_sha1, if (string_list_add_note_lines(&sort_uniq_list, new_sha1)) goto out; string_list_remove_empty_items(&sort_uniq_list, 0); - sort_string_list(&sort_uniq_list); + string_list_sort(&sort_uniq_list); string_list_remove_duplicates(&sort_uniq_list, 0); /* create a new blob object from sort_uniq_list */ @@ -1003,7 +1003,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref, if (!combine_notes) combine_notes = combine_notes_concatenate; - t->root = (struct int_node *) xcalloc(sizeof(struct int_node), 1); + t->root = (struct int_node *) xcalloc(1, sizeof(struct int_node)); t->first_non_note = NULL; t->prev_non_note = NULL; t->ref = notes_ref ? xstrdup(notes_ref) : NULL; @@ -1218,8 +1218,7 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1, if (!sha1) return; - if (!(msg = read_sha1_file(sha1, &type, &msglen)) || !msglen || - type != OBJ_BLOB) { + if (!(msg = read_sha1_file(sha1, &type, &msglen)) || type != OBJ_BLOB) { free(msg); return; } @@ -1243,9 +1242,9 @@ static void format_note(struct notes_tree *t, const unsigned char *object_sha1, if (!ref || !strcmp(ref, GIT_NOTES_DEFAULT_REF)) { strbuf_addstr(sb, "\nNotes:\n"); } else { - if (!prefixcmp(ref, "refs/")) + if (starts_with(ref, "refs/")) ref += 5; - if (!prefixcmp(ref, "notes/")) + if (starts_with(ref, "notes/")) ref += 6; strbuf_addf(sb, "\nNotes (%s):\n", ref); } @@ -1293,9 +1292,9 @@ int copy_note(struct notes_tree *t, void expand_notes_ref(struct strbuf *sb) { - if (!prefixcmp(sb->buf, "refs/notes/")) + if (starts_with(sb->buf, "refs/notes/")) return; /* we're happy */ - else if (!prefixcmp(sb->buf, "notes/")) + else if (starts_with(sb->buf, "notes/")) strbuf_insert(sb, 0, "refs/", 5); else strbuf_insert(sb, 0, "refs/notes/", 11); |