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>
This commit is contained in:
parent
d4f3ae0c43
commit
9fb724f1b9
|
@ -115,7 +115,7 @@ class RebuildCommitGraph extends TextBuiltin {
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected void run() throws Exception {
|
protected void run() throws Exception {
|
||||||
if (!really && !db.getRefDatabase().getAllRefs().isEmpty()) {
|
if (!really && db.getRefDatabase().hasRefs()) {
|
||||||
File directory = db.getDirectory();
|
File directory = db.getDirectory();
|
||||||
String absolutePath = directory == null ? "null" //$NON-NLS-1$
|
String absolutePath = directory == null ? "null" //$NON-NLS-1$
|
||||||
: directory.getAbsolutePath();
|
: directory.getAbsolutePath();
|
||||||
|
|
|
@ -407,6 +407,18 @@ public List<Ref> getAllRefs() throws IOException {
|
||||||
return getRefsByPrefix(ALL);
|
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.
|
* Get the additional reference-like entities from the repository.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
Loading…
Reference in New Issue