diff options
Diffstat (limited to 'notes.c')
-rw-r--r-- | notes.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -248,7 +248,10 @@ static void note_tree_insert(struct notes_tree *t, struct int_node *tree, switch (GET_PTR_TYPE(*p)) { case PTR_TYPE_NULL: assert(!*p); - *p = SET_PTR_TYPE(entry, type); + if (is_null_sha1(entry->val_sha1)) + free(entry); + else + *p = SET_PTR_TYPE(entry, type); return; case PTR_TYPE_NOTE: switch (type) { @@ -264,6 +267,9 @@ static void note_tree_insert(struct notes_tree *t, struct int_node *tree, sha1_to_hex(l->val_sha1), sha1_to_hex(entry->val_sha1), sha1_to_hex(l->key_sha1)); + + if (is_null_sha1(l->val_sha1)) + note_tree_remove(t, tree, n, entry); free(entry); return; } @@ -295,6 +301,10 @@ static void note_tree_insert(struct notes_tree *t, struct int_node *tree, /* non-matching leaf_node */ assert(GET_PTR_TYPE(*p) == PTR_TYPE_NOTE || GET_PTR_TYPE(*p) == PTR_TYPE_SUBTREE); + if (is_null_sha1(entry->val_sha1)) { /* skip insertion of empty note */ + free(entry); + return; + } new_node = (struct int_node *) xcalloc(sizeof(struct int_node), 1); note_tree_insert(t, new_node, n + 1, l, GET_PTR_TYPE(*p), combine_notes); |