From: Han-Wen Nienhuys Date: Sun, 8 Sep 2019 16:02:05 +0000 (+0200) Subject: reftable: add maxUpdateIndex to Reftable X-Git-Tag: v5.6.0.201911271000-m3~109 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=33dc08c162f60acd4d803c721f78c64ddf194be9;p=jgit.git reftable: add maxUpdateIndex to Reftable This makes maxUpdateIndex() available in MergedReftable, so we can know generically at which index to create the next reftable in a stack. Change-Id: Ia2314bc57c8b5dd7e69d5e61096fdce1d35abd11 Signed-off-by: Han-Wen Nienhuys --- 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 c740bf2c37..f5d612f3e1 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 @@ -91,6 +91,15 @@ public class MergedReftable extends Reftable { } } + /** + * {@inheritDoc} + */ + @Override + public long maxUpdateIndex() throws IOException { + return tables.length > 0 ? tables[tables.length - 1].maxUpdateIndex() + : 0; + } + /** {@inheritDoc} */ @Override public RefCursor allRefs() throws IOException { 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 cb02628e8d..f5685c6ca7 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 @@ -98,6 +98,19 @@ public abstract class Reftable implements AutoCloseable { includeDeletes = deletes; } + + /** + * Get the maximum update index for log entries that appear in this + * reftable. + * + * @return the maximum update index for log entries that appear in this + * reftable. This should be 1 higher than the prior reftable's + * {@code maxUpdateIndex} if this table is used in a stack. + * @throws java.io.IOException + * file cannot be read. + */ + public abstract long maxUpdateIndex() throws IOException; + /** * Seek to the first reference, to iterate in order. * 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 02c2f5bba8..75e98958f4 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 @@ -146,15 +146,9 @@ public class ReftableReader extends Reftable { } /** - * Get the maximum update index for log entries that appear in this - * reftable. - * - * @return the maximum update index for log entries that appear in this - * reftable. This should be 1 higher than the prior reftable's - * {@code maxUpdateIndex} if this table is used in a stack. - * @throws java.io.IOException - * file cannot be read. + * {@inheritDoc} */ + @Override public long maxUpdateIndex() throws IOException { if (blockSize == -1) { readFileHeader();