Package com.google.gerrit.server.patch
Interface DiffOperations
-
- All Known Implementing Classes:
DiffOperationsImpl
public interface DiffOperations
An interface for all file diff related operations. Clients should use this interface to request:- The list of modified files between two commits.
- The list of modified files between a commit and its parent or the auto-merge.
- The detailed file diff for a single file path.
- The Intra-line diffs for a single file path (TODO:ghareeb).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FileDiffOutput
getModifiedFile(Project.NameKey project, org.eclipse.jgit.lib.ObjectId oldCommit, org.eclipse.jgit.lib.ObjectId newCommit, String fileName, DiffPreferencesInfo.Whitespace whitespace)
Returns the diff for a single file between two patchset commits.FileDiffOutput
getModifiedFileAgainstParent(Project.NameKey project, org.eclipse.jgit.lib.ObjectId newCommit, Integer parentNum, String fileName, DiffPreferencesInfo.Whitespace whitespace)
Returns the diff for a single file between a patchset commit against its parent or the auto-merge commit.Map<String,FileDiffOutput>
listModifiedFiles(Project.NameKey project, org.eclipse.jgit.lib.ObjectId oldCommit, org.eclipse.jgit.lib.ObjectId newCommit)
Returns the list of added, deleted or modified files between two commits (patchsets).Map<String,FileDiffOutput>
listModifiedFilesAgainstParent(Project.NameKey project, org.eclipse.jgit.lib.ObjectId newCommit, Integer parentNum)
Returns the list of added, deleted or modified files between a commit against its base.
-
-
-
Method Detail
-
listModifiedFilesAgainstParent
Map<String,FileDiffOutput> listModifiedFilesAgainstParent(Project.NameKey project, org.eclipse.jgit.lib.ObjectId newCommit, Integer parentNum) throws DiffNotAvailableException
Returns the list of added, deleted or modified files between a commit against its base. ThePatch.COMMIT_MSG
andPatch.MERGE_LIST
(for merge commits) are also returned.If parentNum is set, it is used as the old commit in the diff. Otherwise, if the
newCommit
has only one parent, it is used as base. IfnewCommit
has two parents, the auto-merge commit is computed and used as base. The auto-merge for more than two parents is not supported.- Parameters:
project
- a project name representing a git repository.newCommit
- 20 bytes SHA-1 of the new commit used in the diff.parentNum
- integer specifying which parent to use as base. If null, the only parent will be used or the auto-merge ifnewCommit
is a merge commit.- Returns:
- the list of modified files between the two commits.
- Throws:
DiffNotAvailableException
- if auto-merge is requested for a commit having more than two parents, if thenewCommit
could not be parsed for extracting the base commit, or if an internal error occurred in Git while evaluating the diff.
-
listModifiedFiles
Map<String,FileDiffOutput> listModifiedFiles(Project.NameKey project, org.eclipse.jgit.lib.ObjectId oldCommit, org.eclipse.jgit.lib.ObjectId newCommit) throws DiffNotAvailableException
Returns the list of added, deleted or modified files between two commits (patchsets). The commit message and merge list (for merge commits) are also returned.- Parameters:
project
- a project name representing a git repository.oldCommit
- 20 bytes SHA-1 of the old commit used in the diff.newCommit
- 20 bytes SHA-1 of the new commit used in the diff.- Returns:
- the list of modified files between the two commits.
- Throws:
DiffNotAvailableException
- if an internal error occurred in Git while evaluating the diff.
-
getModifiedFileAgainstParent
FileDiffOutput getModifiedFileAgainstParent(Project.NameKey project, org.eclipse.jgit.lib.ObjectId newCommit, Integer parentNum, String fileName, DiffPreferencesInfo.Whitespace whitespace) throws DiffNotAvailableException
Returns the diff for a single file between a patchset commit against its parent or the auto-merge commit. For deleted files, thefileName
parameter should contain the old name of the file. This method will returnFileDiffOutput.empty(String, ObjectId, ObjectId)
if the requested file identified byfileName
has unchanged content or does not exist at both commits.- Parameters:
project
- a project name representing a git repository.newCommit
- 20 bytes SHA-1 of the new commit used in the diff.parentNum
- integer specifying which parent to use as base. If null, the only parent will be used or the auto-merge ifnewCommit
is a merge commit.fileName
- the file name for which the diff should be evaluated.whitespace
- preference controlling whitespace effect in diff computation.- Returns:
- the diff for the single file between the two commits.
- Throws:
DiffNotAvailableException
- if an internal error occurred in Git while evaluating the diff, or if an exception happened while parsing the base commit.
-
getModifiedFile
FileDiffOutput getModifiedFile(Project.NameKey project, org.eclipse.jgit.lib.ObjectId oldCommit, org.eclipse.jgit.lib.ObjectId newCommit, String fileName, DiffPreferencesInfo.Whitespace whitespace) throws DiffNotAvailableException
Returns the diff for a single file between two patchset commits. For deleted files, thefileName
parameter should contain the old name of the file. This method will returnFileDiffOutput.empty(String, ObjectId, ObjectId)
if the requested file identified byfileName
has unchanged content or does not exist at both commits.- Parameters:
project
- a project name representing a git repository.oldCommit
- 20 bytes SHA-1 of the old commit used in the diff.newCommit
- 20 bytes SHA-1 of the new commit used in the diff.fileName
- the file name for which the diff should be evaluated.whitespace
- preference controlling whitespace effect in diff computation.- Returns:
- the diff for the single file between the two commits.
- Throws:
DiffNotAvailableException
- if an internal error occurred in Git while evaluating the diff.
-
-