load_subtree(): combine some common code
Write the length into `object_oid` (before copying) rather than `l->key_oid` (after copying). Then combine some code from the two `if` blocks. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
67c9b42251
commit
4ebef533d7
14
notes.c
14
notes.c
|
@ -447,10 +447,6 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
|
||||||
goto handle_non_note; /* entry.path is not a SHA1 */
|
goto handle_non_note; /* entry.path is not a SHA1 */
|
||||||
|
|
||||||
type = PTR_TYPE_NOTE;
|
type = PTR_TYPE_NOTE;
|
||||||
l = (struct leaf_node *)
|
|
||||||
xcalloc(1, sizeof(struct leaf_node));
|
|
||||||
oidcpy(&l->key_oid, &object_oid);
|
|
||||||
oidcpy(&l->val_oid, entry.oid);
|
|
||||||
} else if (path_len == 2) {
|
} else if (path_len == 2) {
|
||||||
/* This is potentially an internal node */
|
/* This is potentially an internal node */
|
||||||
|
|
||||||
|
@ -463,17 +459,17 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
|
||||||
GIT_SHA1_RAWSZ - prefix_len))
|
GIT_SHA1_RAWSZ - prefix_len))
|
||||||
goto handle_non_note; /* entry.path is not a SHA1 */
|
goto handle_non_note; /* entry.path is not a SHA1 */
|
||||||
|
|
||||||
|
object_oid.hash[KEY_INDEX] = (unsigned char) (prefix_len + 1);
|
||||||
|
|
||||||
type = PTR_TYPE_SUBTREE;
|
type = PTR_TYPE_SUBTREE;
|
||||||
l = (struct leaf_node *)
|
|
||||||
xcalloc(1, sizeof(struct leaf_node));
|
|
||||||
oidcpy(&l->key_oid, &object_oid);
|
|
||||||
oidcpy(&l->val_oid, entry.oid);
|
|
||||||
l->key_oid.hash[KEY_INDEX] = (unsigned char) (prefix_len + 1);
|
|
||||||
} else {
|
} else {
|
||||||
/* This can't be part of a note */
|
/* This can't be part of a note */
|
||||||
goto handle_non_note;
|
goto handle_non_note;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
l = xcalloc(1, sizeof(*l));
|
||||||
|
oidcpy(&l->key_oid, &object_oid);
|
||||||
|
oidcpy(&l->val_oid, entry.oid);
|
||||||
if (note_tree_insert(t, node, n, l, type,
|
if (note_tree_insert(t, node, n, l, type,
|
||||||
combine_notes_concatenate))
|
combine_notes_concatenate))
|
||||||
die("Failed to load %s %s into notes tree "
|
die("Failed to load %s %s into notes tree "
|
||||||
|
|
Loading…
Reference in New Issue