Fix isMergedIntoVisibleRef check to handle prefix in RefMap

RefMap does not accept mixed prefixes, as this could cause a
key collision. Adding R_HEADS and R_TAGS to the same RefMap
will always fail.

Instead pull the refs into a List<Ref> and work from that.

Change-Id: I57a463cc462b97e3ed6ac76bc8d8129c88819b03