Class RevFilter

java.lang.Object
org.eclipse.jgit.revwalk.filter.RevFilter
Direct Known Subclasses:
AddToBitmapFilter, AddToBitmapWithCacheFilter, AddUnseenToBitmapFilter, AndRevFilter, BitmappedReachabilityChecker.ReachedFilter, CommitTimeRevFilter, MaxCountRevFilter, NotRevFilter, OrRevFilter, PackWriterBitmapPreparer.NotInBitmapFilter, PatternMatchRevFilter, RevFilter.AllFilter, RevFilter.MergeBaseFilter, RevFilter.NoMergesFilter, RevFilter.NoneFilter, RevFilter.OnlyMergesFilter, RevFlagFilter, SkipRevFilter, SubStringRevFilter, TreeRevFilter

public abstract class RevFilter extends Object
Selects interesting revisions during walking.

This is an abstract interface. Applications may implement a subclass, or use one of the predefined implementations already available within this package. Filters may be chained together using AndRevFilter and OrRevFilter to create complex boolean expressions.

Applications should install the filter on a RevWalk by RevWalk.setRevFilter(RevFilter) prior to starting traversal.

Unless specifically noted otherwise a RevFilter implementation is not thread safe and may not be shared by different RevWalk instances at the same time. This restriction allows RevFilter implementations to cache state within their instances during include(RevWalk, RevCommit) if it is beneficial to their implementation. Deep clones created by clone() may be used to construct a thread-safe copy of an existing filter.

Message filters:

Merge filters:

Boolean modifiers:

  • Field Details

    • ALL

      public static final RevFilter ALL
      Default filter that always returns true (thread safe).
    • NONE

      public static final RevFilter NONE
      Default filter that always returns false (thread safe).
    • ONLY_MERGES

      public static final RevFilter ONLY_MERGES
      Filter including only merge commits, excluding all commits with less than two parents (thread safe).
      Since:
      4.4
    • NO_MERGES

      public static final RevFilter NO_MERGES
      Excludes commits with more than one parent (thread safe).
    • MERGE_BASE

      public static final RevFilter MERGE_BASE
      Selects only merge bases of the starting points (thread safe).

      This is a special case filter that cannot be combined with any other filter. Its include method always throws an exception as context information beyond the arguments is necessary to determine if the supplied commit is a merge base.

  • Constructor Details

    • RevFilter

      public RevFilter()
  • Method Details

    • negate

      public RevFilter negate()
      Create a new filter that does the opposite of this filter.
      Returns:
      a new filter that includes commits this filter rejects.
    • requiresCommitBody

      public boolean requiresCommitBody()
      Whether the filter needs the commit body to be parsed.
      Returns:
      true if the filter needs the commit body to be parsed.
    • include

      public abstract boolean include(RevWalk walker, RevCommit cmit) throws StopWalkException, MissingObjectException, IncorrectObjectTypeException, IOException
      Determine if the supplied commit should be included in results.
      Parameters:
      walker - the active walker this filter is being invoked from within.
      cmit - the commit currently being tested. The commit has been parsed and its body is available for inspection only if the filter returns true from requiresCommitBody().
      Returns:
      true to include this commit in the results; false to have this commit be omitted entirely from the results.
      Throws:
      StopWalkException - the filter knows for certain that no additional commits can ever match, and the current commit doesn't match either. The walk is halted and no more results are provided.
      MissingObjectException - an object the filter needs to consult to determine its answer does not exist in the Git repository the walker is operating on. Filtering this commit is impossible without the object.
      IncorrectObjectTypeException - an object the filter needed to consult was not of the expected object type. This usually indicates a corrupt repository, as an object link is referencing the wrong type.
      IOException - a loose object or pack file could not be read to obtain data necessary for the filter to make its decision.
    • clone

      public abstract RevFilter clone()

      Clone this revision filter, including its parameters.

      This is a deep clone. If this filter embeds objects or other filters it must also clone those, to ensure the instances do not share mutable data.

      Overrides:
      clone in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object