Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2019-12-05 00:31:32 +0000
committerMatthias Sohn2019-12-05 00:31:32 +0000
commit08d4c63b6dffd6f2314f7ec6de24c1dd9070a44b (patch)
tree9080443f7412e05d71926d86980c4e5fb96ddc24 /org.eclipse.jgit
parent3ca340d5daea9d33fbfb08d4af6e2d851d90cf52 (diff)
parent5185d288c11171a21a3057f0df906782493d0b39 (diff)
downloadjgit-08d4c63b6dffd6f2314f7ec6de24c1dd9070a44b.tar.gz
jgit-08d4c63b6dffd6f2314f7ec6de24c1dd9070a44b.tar.xz
jgit-08d4c63b6dffd6f2314f7ec6de24c1dd9070a44b.zip
Merge branch 'stable-5.6'
* stable-5.6: Introduce RefDatabase#hasFastTipsWithSha1 Update Orbit to R20191126223242 for 2019-12 Prepare 5.6.0-SNAPSHOT builds JGit v5.6.0.201912041214-rc1 Prepare 5.6.0-SNAPSHOT builds JGit v5.6.0.201911271000-m3 Change-Id: Id33b054131bbcd27a0ae7200f564775049698d2c
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReftableDatabase.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/Reftable.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java14
7 files changed, 65 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReftableDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReftableDatabase.java
index 2ad3ae7e62..124131d1d3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReftableDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReftableDatabase.java
@@ -218,6 +218,12 @@ public class DfsReftableDatabase extends DfsRefDatabase {
/** {@inheritDoc} */
@Override
+ public boolean hasFastTipsWithSha1() throws IOException {
+ return reftableDatabase.hasFastTipsWithSha1();
+ }
+
+ /** {@inheritDoc} */
+ @Override
public Ref peel(Ref ref) throws IOException {
Ref oldLeaf = ref.getLeaf();
if (oldLeaf.isPeeled() || oldLeaf.getObjectId() == null) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java
index b06fd30b34..fd80ad9ec0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableDatabase.java
@@ -125,6 +125,12 @@ public class FileReftableDatabase extends RefDatabase {
&& new File(repoDir, Constants.REFTABLE).isDirectory();
}
+ /** {@inheritDoc} */
+ @Override
+ public boolean hasFastTipsWithSha1() throws IOException {
+ return reftableDatabase.hasFastTipsWithSha1();
+ }
+
/**
* Runs a full compaction for GC purposes.
* @throws IOException on I/O errors
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java
index 4de5e392f9..6c312ca7a0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java
@@ -100,6 +100,16 @@ public class MergedReftable extends Reftable {
/** {@inheritDoc} */
@Override
+ public boolean hasObjectMap() throws IOException {
+ boolean has = true;
+ for (int i = 0; has && i < tables.length; i++) {
+ has = has && tables[i].hasObjectMap();
+ };
+ return has;
+ }
+
+ /** {@inheritDoc} */
+ @Override
public RefCursor allRefs() throws IOException {
MergedRefCursor m = new MergedRefCursor();
for (int i = 0; i < tables.length; i++) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/Reftable.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/Reftable.java
index 8f64261766..8a8a14375a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/Reftable.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/Reftable.java
@@ -162,6 +162,12 @@ public abstract class Reftable {
public abstract RefCursor byObjectId(AnyObjectId id) throws IOException;
/**
+ * @return whether this reftable can do a fast SHA1 => ref lookup.
+ * @throws IOException on I/O problems.
+ */
+ public abstract boolean hasObjectMap() throws IOException;
+
+ /**
* Seek reader to read log records.
*
* @return cursor to iterate; empty cursor if no logs are present.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java
index 5a32d29144..c08f1814dc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableDatabase.java
@@ -299,6 +299,19 @@ public abstract class ReftableDatabase {
}
/**
+ * @return whether there is a fast SHA1 to ref map.
+ * @throws IOException in case of I/O problems.
+ */
+ public boolean hasFastTipsWithSha1() throws IOException {
+ lock.lock();
+ try {
+ return reader().hasObjectMap();
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
* Returns all refs that resolve directly to the given {@link ObjectId}.
* Includes peeled {@linkObjectId}s.
*
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
index c5e667449a..14b821a1ed 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
@@ -128,6 +128,16 @@ public class ReftableReader extends Reftable implements AutoCloseable {
return blockSize;
}
+ @Override
+ public boolean hasObjectMap() throws IOException {
+ if (objIndexPosition == -1) {
+ readFileFooter();
+ }
+
+ // We have the map, we have no refs, or the table is small.
+ return (objPosition > 0 || refEnd == 24 || refIndexPosition == 0);
+ }
+
/**
* Get the minimum update index for log entries that appear in this
* reftable.
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 4d9450e758..9b5a1fdc22 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java
@@ -497,6 +497,20 @@ public abstract class RefDatabase {
}
/**
+ * If the ref database does not support fast inverse queries, it may
+ * be advantageous to build a complete SHA1 to ref map in advance for
+ * multiple uses. To let applications decide on this decision,
+ * this function indicates whether the inverse map is available.
+ *
+ * @return whether this RefDatabase supports fast inverse ref queries.
+ * @throws IOException on I/O problems.
+ * @since 5.6
+ */
+ public boolean hasFastTipsWithSha1() throws IOException {
+ return false;
+ }
+
+ /**
* Check if any refs exist in the ref database.
* <p>
* This uses the same definition of refs as {@link #getRefs()}. In

Back to the top