Class CommitDiff
java.lang.Object
org.variantsync.diffdetective.diff.git.CommitDiff
Represents the changes made by a commit relative to another commit.
A CommitDiff stores the current commit's id as well as we parent commit id.
The diff represents the changes made by the current comment to the parent commit.
The changes are represented by a list of
PatchDiffs as a commit modifies a set
of files.
This is a data class that does not provide functionality.- Author:
- Sören Viegener, Paul Bittner
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe hash of the current commit.static final String(package private) final booleanprivate final StringThe hash of the parent commit.A list of allPatchDiffsof aCommitDiff. -
Constructor Summary
ConstructorsConstructorDescriptionCommitDiff(org.eclipse.jgit.revwalk.RevCommit commit, org.eclipse.jgit.revwalk.RevCommit parent) Creates a new diff for the following two commits. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPatchDiff(PatchDiff patchDiff) Add aPatchDiff.Returns this commit's hash abbreviated to the first eight characters.getAbbreviatedCommitHash(int length) Returns the first n characters of this commit's hash.Returns the full commit hash of this commit.Returns the fill commit hash of the parent commit.intReturns the amount ofPatchDiffsthat belong to thisCommitDiff.Returns the list of allPatchDiffsthat belong to thisCommitDiff.booleanReturns true iff this commit is a merge commit.toString()
-
Field Details
-
INVALID_COMMIT_HASH
- See Also:
-
patchDiffs
A list of allPatchDiffsof aCommitDiff. -
parentCommitHash
The hash of the parent commit. -
commitHash
The hash of the current commit. -
merge
final boolean merge
-
-
Constructor Details
-
CommitDiff
public CommitDiff(org.eclipse.jgit.revwalk.RevCommit commit, org.eclipse.jgit.revwalk.RevCommit parent) Creates a new diff for the following two commits. The resulting CommitDiff is empty meaning that it does not contain any PatchDiffs.- Parameters:
commit- The commit whose changes are stored relative to parent.parent- The commit to which changes are compared.- See Also:
-
-
Method Details
-
addPatchDiff
Add aPatchDiff. The given diff should belong to the changes between the commits of this CommitDiff.- Parameters:
patchDiff- ThePatchDiffto be added
-
getPatchDiffs
Returns the list of allPatchDiffsthat belong to thisCommitDiff. -
getPatchAmount
public int getPatchAmount()Returns the amount ofPatchDiffsthat belong to thisCommitDiff. -
isMergeCommit
public boolean isMergeCommit()Returns true iff this commit is a merge commit. -
getAbbreviatedCommitHash
Returns the first n characters of this commit's hash.- Parameters:
length- The number of characters to include in the commit hash.
-
getAbbreviatedCommitHash
Returns this commit's hash abbreviated to the first eight characters. The first eight characters are usually unique if a commit history does not become too large. -
getCommitHash
Returns the full commit hash of this commit. -
getParentCommitHash
Returns the fill commit hash of the parent commit.- See Also:
-
toString
-