From 9fb724f1b9f9f6920852a922abe2c316fc8d25d6 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Fri, 27 Apr 2018 21:49:08 +0900 Subject: RefDatabase: add hasRefs convenience method Callers can now say: db.getRefDatabase().hasRefs() rather than the more verbose: !db.getRefDatabase().getAllRefs().isEmpty() The default implementation simply uses getAllRefs().isEmpty(), but a derived class could possibly override the method with a more efficient implementation. Change-Id: I5244520708a1a7d9adb351f10e43fc39d98e22a1 Signed-off-by: David Pursehouse --- org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'org.eclipse.jgit/src') diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java index bceb208292..0ae14d1304 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java @@ -407,6 +407,18 @@ public abstract class RefDatabase { return getRefsByPrefix(ALL); } + /** + * Check if any refs exist in the ref database. + * + * @return true if the database has refs. + * @throws java.io.IOException + * the reference space cannot be accessed. + * @since 5.0 + */ + public boolean hasRefs() throws IOException { + return !getAllRefs().isEmpty(); + } + /** * Get the additional reference-like entities from the repository. *

-- cgit v1.2.3