{"push_id":1642189138,"size":2,"distinct_size":2,"ref":"refs/heads/pu","head":"5cd76d39ee5821c9788b027ce2678c2a52927ed0","before":"2d135e704ed641ed6351678f8dfeda9029527bbd","commits":[{"sha":"5a8e7c346672e399a6b6c0335a4435c7264a2a32","author":{"name":"Mike Hommey","email":"0fa1ec019f545602546f76c862df558442f914ca@glandium.org"},"message":"notes: do not break note_tree structure in note_tree_consolidate()\n\nAfter a note is removed, note_tree_consolidate is called to eliminate\nsome useless nodes. The typical case is that if you had an int_node\nwith 2 PTR_TYPE_NOTEs in it, and remove one of them, then the\nPTR_TYPE_INTERNAL pointer in the parent tree can be replaced with the\nremaining PTR_TYPE_NOTE.\n\nThis works fine when PTR_TYPE_NOTEs are involved, but falls flat when\nother types are involved.\n\nTo put things in more practical terms, let's say we start from an empty\nnotes tree, and add 3 notes:\n\n- one for a sha1 that starts with 424\n- one for a sha1 that starts with 428\n- one for a sha1 that starts with 4c\n\nTo keep track of this, note_tree.root will have a PTR_TYPE_INTERNAL at\na[4], pointing to an int_node*.\nIn turn, that int_node* will have a PTR_TYPE_NOTE at a[0xc], pointing to\nthe leaf_node* with the key and value, and a PTR_TYPE_INTERNAL at a[2],\npointing to another int_node*.\nThat other int_node* will have 2 PTR_TYPE_NOTE, one at a[4] and the\nother at a[8].\n\nWhen looking for the note for the sha1 starting with 428, get_note() will\nrecurse through (simplified) root.a[4].a[2].a[8].\n\nNow, if we remove the note for the sha1 that starts with 4c, we're left\nwith a int_node* with only one PTR_TYPE_INTERNAL entry in it. After\nnote_tree_consolidate runs, root.a[4] now points to what used to be\npointed at by root.a[4].a[2].\n\nWhich means looking up for the note for the sha1 starting with 428 now\nfails because there is nothing at root.a[4].a[2] anymore: there is only\nroot.a[4].a[4] and root.a[4].a[8], which don't match the expected\nstructure for the lookup.\n\nSo if all there is left in an int_node* is a PTR_TYPE_INTERNAL pointer,\nwe can't safely remove it. I think the same applies for PTR_TYPE_SUBTREE\npointers. IOW, only PTR_TYPE_NOTEs are safe to be moved to the parent\nint_node*.\n\nThis doesn't have a practical effect on git because all that happens\nafter a remove_note is a write_notes_tree, which just iterates the entire\nnote tree, but this affects anything using libgit.a that would try to do\nlookups after removing notes.\n\nSigned-off-by: Mike Hommey <mh@glandium.org>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>","distinct":true,"url":"https://api.github.com/repos/git/git/commits/5a8e7c346672e399a6b6c0335a4435c7264a2a32"},{"sha":"5cd76d39ee5821c9788b027ce2678c2a52927ed0","author":{"name":"Junio C Hamano","email":"3228067b6039a0d99bddaf967dafdecd5cc61600@pobox.com"},"message":"Merge branch 'mh/notes-tree-consolidate-fix' into pu\n\n* mh/notes-tree-consolidate-fix:\n  notes: do not break note_tree structure in note_tree_consolidate()","distinct":true,"url":"https://api.github.com/repos/git/git/commits/5cd76d39ee5821c9788b027ce2678c2a52927ed0"}]}
{"actor":{"display_login":"gitster"}}