java.lang.Object
org.eclipse.jgit.internal.storage.reftable.Reftable
Direct Known Subclasses:
MergedReftable, ReftableReader

public abstract class Reftable extends Object
Abstract table of references.
  • Field Details

    • includeDeletes

      protected boolean includeDeletes
      true if deletions should be included in results.
  • Constructor Details

    • Reftable

      public Reftable()
  • Method Details

    • from

      public static Reftable from(Collection<Ref> refs)
      References to convert into a reftable
      Parameters:
      refs - references to convert into a reftable; may be empty.
      Returns:
      a reader for the supplied references.
    • setIncludeDeletes

      public void setIncludeDeletes(boolean deletes)
      Whether deleted references will be returned.
      Parameters:
      deletes - if true deleted references will be returned. If false (default behavior), deleted references will be skipped, and not returned.
    • maxUpdateIndex

      public abstract long maxUpdateIndex() throws IOException
      Get the maximum update index for ref entries that appear in this reftable.
      Returns:
      the maximum update index for ref entries that appear in this reftable.
      Throws:
      IOException - file cannot be read.
    • minUpdateIndex

      public abstract long minUpdateIndex() throws IOException
      Get the minimum update index for ref entries that appear in this reftable.
      Returns:
      the minimum update index for ref entries that appear in this reftable.
      Throws:
      IOException - file cannot be read.
    • allRefs

      public abstract RefCursor allRefs() throws IOException
      Seek to the first reference, to iterate in order.
      Returns:
      cursor to iterate.
      Throws:
      IOException - if references cannot be read.
    • seekRef

      public abstract RefCursor seekRef(String refName) throws IOException
      Seek to a reference.

      This method will seek to the reference refName. If present, the returned cursor will iterate exactly one entry. If not found, an empty cursor is returned.

      Parameters:
      refName - reference name.
      Returns:
      cursor to iterate; empty cursor if no references match.
      Throws:
      IOException - if references cannot be read.
    • seekRefsWithPrefix

      public abstract RefCursor seekRefsWithPrefix(String prefix) throws IOException
      Seek references with prefix.

      The method will seek all the references starting with prefix as a prefix. If no references start with this prefix, an empty cursor is returned.

      Parameters:
      prefix - prefix to find.
      Returns:
      cursor to iterate; empty cursor if no references match.
      Throws:
      IOException - if references cannot be read.
    • byObjectId

      public abstract RefCursor byObjectId(AnyObjectId id) throws IOException
      Match references pointing to a specific object.
      Parameters:
      id - object to find.
      Returns:
      cursor to iterate; empty cursor if no references match.
      Throws:
      IOException - if references cannot be read.
    • hasObjectMap

      public abstract boolean hasObjectMap() throws IOException
      Returns:
      whether this reftable can do a fast SHA1 => ref lookup.
      Throws:
      IOException - on I/O problems.
    • allLogs

      public abstract LogCursor allLogs() throws IOException
      Seek reader to read log records.
      Returns:
      cursor to iterate; empty cursor if no logs are present.
      Throws:
      IOException - if logs cannot be read.
    • seekLog

      public LogCursor seekLog(String refName) throws IOException
      Read a single reference's log.
      Parameters:
      refName - exact name of the reference whose log to read.
      Returns:
      cursor to iterate; empty cursor if no logs match.
      Throws:
      IOException - if logs cannot be read.
    • seekLog

      public abstract LogCursor seekLog(String refName, long updateIndex) throws IOException
      Seek to an update index in a reference's log.
      Parameters:
      refName - exact name of the reference whose log to read.
      updateIndex - most recent index to return first in the log cursor. Log records at or before updateIndex will be returned.
      Returns:
      cursor to iterate; empty cursor if no logs match.
      Throws:
      IOException - if logs cannot be read.
    • exactRef

      @Nullable public Ref exactRef(String refName) throws IOException
      Lookup a reference, or null if not found.
      Parameters:
      refName - reference name to find.
      Returns:
      the reference, or null if not found.
      Throws:
      IOException - if references cannot be read.
    • hasRef

      public boolean hasRef(String refName) throws IOException
      Test if a reference exists.
      Parameters:
      refName - reference name or subtree to find.
      Returns:
      true if the reference exists.
      Throws:
      IOException - if references cannot be read.
    • hasRefsWithPrefix

      public boolean hasRefsWithPrefix(String prefix) throws IOException
      Test if any reference starts with prefix as a prefix.
      Parameters:
      prefix - prefix to find.
      Returns:
      true if at least one reference exists with prefix.
      Throws:
      IOException - if references cannot be read.
    • hasId

      public boolean hasId(AnyObjectId id) throws IOException
      Test if any reference directly refers to the object.
      Parameters:
      id - ObjectId to find.
      Returns:
      true if any reference exists directly referencing id, or a annotated tag that peels to id.
      Throws:
      IOException - if references cannot be read.
    • resolve

      @Nullable public Ref resolve(Ref symref) throws IOException
      Resolve a symbolic reference to populate its value.
      Parameters:
      symref - reference to resolve.
      Returns:
      resolved symref, or null.
      Throws:
      IOException - if references cannot be read.
    • resolve

      private Ref resolve(Ref ref, int depth) throws IOException
      Throws:
      IOException