ForProject: Deduplicate refs when converting to map

This implementation has no control over the ref list that is passed in.
One place where this is called is from DefaultAdvertiseRefsHook, which
passes a caller-provided set of prefixes that may overlap.
getRefsByPrefix is explicitly documented to return duplicate refs when
prefixes overlap.

In preparing this change, I inspected all instances of toMap in the diff
of b024eef9~..a9d003ed to catch recently-introduced issues. This was the
only one that was not converting the entire set of refs; in the latter
case, those do not contain duplicates.

Change-Id: I2541ef924406a5c09b47a54be0735451c6357173
diff --git a/java/com/google/gerrit/server/permissions/PermissionBackend.java b/java/com/google/gerrit/server/permissions/PermissionBackend.java
index f0f7f42..a87eb24 100644
--- a/java/com/google/gerrit/server/permissions/PermissionBackend.java
+++ b/java/com/google/gerrit/server/permissions/PermissionBackend.java
@@ -348,7 +348,7 @@
      */
     public Map<String, Ref> filter(List<Ref> refs, Repository repo, RefFilterOptions opts)
         throws PermissionBackendException {
-      return filter(refs.stream().collect(toMap(Ref::getName, r -> r)), repo, opts);
+      return filter(refs.stream().collect(toMap(Ref::getName, r -> r, (a, b) -> b)), repo, opts);
     }
   }