Class ModifiedFilesLoader

java.lang.Object
com.google.gerrit.server.patch.diff.ModifiedFilesLoader

public class ModifiedFilesLoader extends Object
Class to load the files that have been modified between two commits.

Rename detection is off unless withRenameDetection(int) is called.

The commits and their trees are looked up via the RevWalk instance that is provided to the load(com.google.gerrit.entities.Project.NameKey, Config, RevWalk, ObjectId, ObjectId) method, unless the modified files for the trees of the commits should be retrieved from the GitModifiedFilesCache (see ModifiedFilesLoader.Factory.createWithRetrievingModifiedFilesForTreesFromGitModifiedFilesCache() in which case the trees are looked up via a new RevWalk instance that is created by GitModifiedFilesCacheImpl.Loader. Looking up the trees from a new RevWalk instance only succeeds if they were already fully persisted in the repository, i.e., if these are not newly created trees or tree which have been created in memory. This means using the GitModifiedFilesCache is expected to cause MissingObjectExceptions for the commit trees that are newly created or that were created in memory only.

  • Method Details

    • withRenameDetection

      @CanIgnoreReturnValue public ModifiedFilesLoader withRenameDetection(int renameScore)
      Enables rename detection
      Parameters:
      renameScore - the score that should be used for the rename detection.
    • load

      public com.google.common.collect.ImmutableList<ModifiedFile> load(Project.NameKey project, org.eclipse.jgit.lib.Config repoConfig, org.eclipse.jgit.revwalk.RevWalk revWalk, org.eclipse.jgit.lib.ObjectId baseCommit, org.eclipse.jgit.lib.ObjectId newCommit) throws DiffNotAvailableException
      Loads the files that have been modified between baseCommit and newCommit.

      The commits and the commit trees are looked up via the given revWalk instance, unless the modified files for the trees of the commits should be retrieved from the GitModifiedFilesCache (see ModifiedFilesLoader.Factory.createWithRetrievingModifiedFilesForTreesFromGitModifiedFilesCache() in which case the trees are looked up via a new RevWalk instance that is created by GitModifiedFilesCacheImpl.Loader. Also see the javadoc on this class.

      Throws:
      DiffNotAvailableException