diff options
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java | 2 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java index 666fc34e26..19d94eadef 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/RebuildCommitGraph.java @@ -115,7 +115,7 @@ class RebuildCommitGraph extends TextBuiltin { /** {@inheritDoc} */ @Override protected void run() throws Exception { - if (!really && !db.getRefDatabase().getAllRefs().isEmpty()) { + if (!really && db.getRefDatabase().hasRefs()) { File directory = db.getDirectory(); String absolutePath = directory == null ? "null" //$NON-NLS-1$ : directory.getAbsolutePath(); 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 |