Interface CommitGraph


public interface CommitGraph
The CommitGraph is a supplemental data structure that accelerates commit graph walks.

If a user downgrades or disables the core.commitGraph config setting, then the existing object database is sufficient.

It stores the commit graph structure along with some extra metadata to speed up graph walks. By listing commit OIDs in lexicographic order, we can identify an integer position for each commit and refer to the parents of a commit using those integer positions. We use binary search to find initial commits and then use the integer positions for fast lookups during the walk.

  • Field Details

  • Method Details

    • findGraphPosition

      int findGraphPosition(AnyObjectId commit)
      Find the position in the commit-graph of the commit.

      The position can only be used within the CommitGraph Instance you got it from. That's because the graph position of the same commit may be different in CommitGraph obtained at different times (eg., regenerated new commit-graph).

      Parameters:
      commit - the commit for which the commit-graph position will be found.
      Returns:
      the commit-graph position or -1 if the object was not found.
    • getCommitData

      CommitGraph.CommitData getCommitData(int graphPos)
      Get the metadata of a commit。

      This function runs in time O(1).

      In the process of commit history traversal, CommitGraph.CommitData.getParents() makes us get the graphPos of the commit's parents in advance, so that we can avoid O(logN) lookup and use O(1) lookup instead.

      Parameters:
      graphPos - the position in the commit-graph of the object.
      Returns:
      the metadata of a commit or null if it's not found.
    • getObjectId

      ObjectId getObjectId(int graphPos)
      Get the object at the commit-graph position.
      Parameters:
      graphPos - the position in the commit-graph of the object.
      Returns:
      the ObjectId or null if it's not found.
    • getChangedPathFilter

      ChangedPathFilter getChangedPathFilter(int graphPos)
      Get the changed path filter of the object at the commit-graph position.
      Parameters:
      graphPos - the position in the commit-graph of the object.
      Returns:
      the bloom filter or null if it's not found.
    • getCommitCnt

      long getCommitCnt()
      Obtain the total number of commits described by this commit-graph.
      Returns:
      number of commits in this commit-graph.