diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java index dcf30c713..83127eb54 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java @@ -74,6 +74,7 @@ import java.text.MessageFormat; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -350,6 +351,43 @@ public class RefDirectory extends RefDatabase { } } + /** {@inheritDoc} */ + @Override + @NonNull + public Map exactRef(String... refs) throws IOException { + try { + RefList packed = getPackedRefs(); + Map result = new HashMap<>(refs.length); + for (String name : refs) { + Ref ref = readAndResolve(name, packed); + if (ref != null) { + result.put(name, ref); + } + } + return result; + } finally { + fireRefsChanged(); + } + } + + /** {@inheritDoc} */ + @Override + @Nullable + public Ref firstExactRef(String... refs) throws IOException { + try { + RefList packed = getPackedRefs(); + for (String name : refs) { + Ref ref = readAndResolve(name, packed); + if (ref != null) { + return ref; + } + } + return null; + } finally { + fireRefsChanged(); + } + } + /** {@inheritDoc} */ @Override public Ref getRef(String needle) throws IOException {