See my note above on the old version.  We need to add headId to the *front* of parents.  The current branch goes first in the parent list, then the values of MERGE_HEAD, in order.  This is necessary to preserve the behavior of --first-parent logic during revision traversal.