Class PackedRefsWriter

java.lang.Object
org.eclipse.jgit.lib.PackedRefsWriter
Direct Known Subclasses:
RefWriter

public abstract class PackedRefsWriter extends Object
Writes out refs to Constants.PACKED_REFS file by computing and applying all the missing traits for optimized reads.
Since:
7.7
  • Field Details

  • Constructor Details

    • PackedRefsWriter

      public PackedRefsWriter(Collection<Ref> refs, EnumSet<PackedRefsTrait> traits, RefDatabase refDb) throws IOException

      Constructor for PackedRefsWriter.

      Parameters:
      refs - the complete set of references. This should have been computed by applying updates to the advertised refs already discovered.
      traits - traits that are applicable to the refs. If any traits are missing, they would be applied before writing, but the specified traits are not re-computed/checked.
      refDb - refDb where the packed-refs file should be written.
      Throws:
      IOException - if it is not able to peel any of the tags.
      Since:
      7.7
    • PackedRefsWriter

      protected PackedRefsWriter(Collection<Ref> refs, EnumSet<PackedRefsTrait> traits)

      Constructor for PackedRefsWriter.

      Stores the provided refs and traits without applying any missing traits. Intended for use by subclasses that manage trait application themselves.

      Parameters:
      refs - the complete set of references. This should have been computed by applying updates to the advertised refs already discovered.
      traits - traits that are applicable to the refs.
  • Method Details

    • writeInfoRefs

      public void writeInfoRefs() throws IOException
      Rebuild the Constants.INFO_REFS.

      This method rebuilds the contents of the Constants.INFO_REFS file to match the passed list of references.

      Throws:
      IOException - writing is not supported, or attempting to write the file failed, possibly due to permissions or remote disk full, etc.
    • writePackedRefs

      public void writePackedRefs() throws IOException
      Rebuild the Constants.PACKED_REFS file.

      This method rebuilds the contents of the Constants.PACKED_REFS file to match the passed list of references, including only those refs that have a storage type of Ref.Storage.PACKED.

      Throws:
      IOException - writing is not supported, or attempting to write the file failed, possibly due to permissions or remote disk full, etc.
    • asRefList

      public RefList<Ref> asRefList()
      Access the new refs after all the necessary traits were applied.
      Returns:
      refs with all the traits applied
    • writeFile

      protected abstract void writeFile(String file, byte[] content) throws IOException
      Handles actual writing of ref files to the git repository, which may differ slightly depending on the destination and transport.
      Parameters:
      file - path to ref file.
      content - byte content of file to be written.
      Throws:
      IOException - if an IO error occurred