The problem with a HashMap is it doesn't preserve the order the caller passed the commits to us in.  We should maintain that order, because its the order we'll attempt to do the octopus merge in, and the order we write the parents out in the commit as.  If you keep using a Map<String,ObjectId> here you should use a LinkedHashMap to ensure the insertion order is preserved.  Or, switch to a List<Ref>.