diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-04-27 21:49:08 +0900 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2018-04-29 22:03:07 +0200 |
commit | 9fb724f1b9f9f6920852a922abe2c316fc8d25d6 (patch) | |
tree | edb0ff72663e2fe7f101d18197c327302fadf003 /org.eclipse.jgit/src | |
parent | d4f3ae0c43c5602b0ca17f4274ee4ffb928f8f7f (diff) | |
download | jgit-9fb724f1b9f9f6920852a922abe2c316fc8d25d6.tar.gz jgit-9fb724f1b9f9f6920852a922abe2c316fc8d25d6.zip |
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 <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java | 12 |
1 files changed, 12 insertions, 0 deletions
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 @@ -408,6 +408,18 @@ public abstract class RefDatabase { } /** + * 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. * <p> * The result list includes non-ref items such as MERGE_HEAD and |