Class TreeWalkConnectivityChecker

java.lang.Object
org.eclipse.jgit.internal.transport.connectivity.TreeWalkConnectivityChecker
All Implemented Interfaces:
ConnectivityChecker

public class TreeWalkConnectivityChecker extends Object implements ConnectivityChecker
A connectivity checker that avoids the object allocations that occur when doing standard graph coloring via ObjectWalk. TreeWalkConnectivityChecker requires the PackParser to report new objects in the pack, and will fail immediately if that is not configured. The ObjectWalk-based algorithm marks objects interesting and uninteresting and parses new subtrees and blobs to propagate those states. Each propagation of state to a child node requires a Java object allocation. This algorithm is closer to the diff algorithm. It parses tree objects at common paths and compares hash values in those trees. Objects only need to be created for subtrees that differ. The tree connectivity part of this algorithm always creates O(commits + tree objects in the new pack) Java objects, independent of where the parent commit is in the graph, and independent of the number of references. (Caveat, it does a standard reachability check if a parent commit is not in advertised "haves", and a standard object reachability check for any base objects referenced in a thin pack.) The ObjectWalk-based algorithm is equivalent to this algorithm when the parents of new commits are all in the advertised "haves", creating O(commit + tree objects in the new pack) Java objects. It is much less efficient otherwise, creating either O(tree objects in checkout) or O(all objects in checkout) Java objects. This algorithm first validates that the commits in the commands (new branch tips) are connected. Starting with those commits, it walks back until a commit not in the pack is found, or until a commit with no parents is found. If a parent commit id is not in the database, connectivity fails. If the parent commit is in the database and was present in the "haves" advertised for the client, it moves on to verifying tree connectivity. Otherwise, it performs a reachability check to make sure the client has access to the unadvertised parent commit, and proceeds to verifying tree connectivity if that succeeds. Tree connectivity is verified for every commit in the receive pack that was visited when checking commit connectivity. For each commit, get its root tree and the root trees of its parents. For each path segment in the child commit's root tree, do the following (includes recursing into differing subtrees, where the same actions are applied):
  • if a blob or subtree's id is identical to one of the parent's blob or subtree's ids, continue/li>
  • if a new blob id is not present in the database, connectivity fails
  • if a new subtree id is present in the pack, traverse into the subtree to continue the check, performing the same actions in this list
  • if the new subtree id is not in the pack but is present in the database, continue/li>
  • if the new subtree id is not in either the pack or the database, connectivity fails