Fix possible NPE when auto-closing changes

Before [1] all refs in existingRefs were guaranteed to be patchset refs,
whereas the refs taken from ReceivePackRefsCache are all refs in the
"refs/changes/*" namespace and these aren't guaranteed to be patchset
refs.

While walking the commits from new tip to previous tip to find open
changes that should be closed by the push, possible patchset-refs are
collected from ReceivePackRefsCache.
Check if the found refs actually are patchset-refs before attempting
to parse it into a Patchset.Id.

[1] https://gerrit-review.googlesource.com/c/gerrit/+/241932

Bug: Issue 13408
Change-Id: Ifafdbba79c436ced406914937ba259eccea7c84f
diff --git a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
index ff28d69..870445f 100644
--- a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
+++ b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
@@ -3272,6 +3272,9 @@
 
                       for (Ref ref :
                           receivePackRefCache.tipsFromObjectId(c.copy(), RefNames.REFS_CHANGES)) {
+                        if (!PatchSet.isChangeRef(ref.getName())) {
+                          continue;
+                        }
                         PatchSet.Id psId = PatchSet.Id.fromRef(ref.getName());
                         Optional<ChangeNotes> notes = getChangeNotes(psId.changeId());
                         if (notes.isPresent() && notes.get().getChange().getDest().equals(branch)) {