public class DiffEntry
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
DiffEntry.ChangeType
General type of change a single file-level patch describes.
|
static class |
DiffEntry.Side
Specify the old or new side for more generalized access.
|
Modifier and Type | Field and Description |
---|---|
(package private) static AbbreviatedObjectId |
A_ZERO
Magical SHA1 used for file adds or deletes
|
protected DiffEntry.ChangeType |
changeType
General type of change indicated by the patch.
|
static java.lang.String |
DEV_NULL
Magical file name used for file adds or deletes.
|
protected Attribute |
diffAttribute
diff filter attribute
|
protected AbbreviatedObjectId |
newId
ObjectId listed on the index line for the new (post-image)
|
protected FileMode |
newMode
New mode of the file, if described by the patch, else null.
|
protected java.lang.String |
newPath
File name of the new (post-image).
|
protected AbbreviatedObjectId |
oldId
ObjectId listed on the index line for the old (pre-image)
|
protected FileMode |
oldMode
Old mode of the file, if described by the patch, else null.
|
protected java.lang.String |
oldPath
File name of the old (pre-image).
|
protected int |
score
Similarity score if
changeType is a copy or rename. |
private int |
treeFilterMarks
Bitset for marked flags of tree filters passed to
scan(TreeWalk, boolean, TreeFilter...) |
Modifier | Constructor and Description |
---|---|
protected |
DiffEntry()
Create an empty DiffEntry
|
Modifier and Type | Method and Description |
---|---|
(package private) static DiffEntry |
add(java.lang.String path,
AnyObjectId id) |
(package private) static java.util.List<DiffEntry> |
breakModify(DiffEntry entry)
Breaks apart a DiffEntry into two entries, one DELETE and one ADD.
|
(package private) static DiffEntry |
delete(java.lang.String path,
AnyObjectId id) |
DiffEntry.ChangeType |
getChangeType()
Get the change type
|
Attribute |
getDiffAttribute() |
AbbreviatedObjectId |
getId(DiffEntry.Side side)
Get the object id.
|
FileMode |
getMode(DiffEntry.Side side)
Get the mode associated with this file.
|
AbbreviatedObjectId |
getNewId()
Get the new object id from the
index . |
FileMode |
getNewMode()
Get the new file mode
|
java.lang.String |
getNewPath()
Get the new name associated with this file.
|
AbbreviatedObjectId |
getOldId()
Get the old object id from the
index . |
FileMode |
getOldMode()
Get the old file mode
|
java.lang.String |
getOldPath()
Get the old name associated with this file.
|
java.lang.String |
getPath(DiffEntry.Side side)
Get the path associated with this file.
|
int |
getScore()
Get similarity score
|
int |
getTreeFilterMarks()
Get the raw tree filter marks, as set during
scan(TreeWalk, boolean, TreeFilter...) . |
boolean |
isMarked(int index)
Whether the mark tree filter with the specified index matched during scan
or not, see
scan(TreeWalk, boolean, TreeFilter...) . |
(package private) static DiffEntry |
modify(java.lang.String path) |
(package private) static DiffEntry |
pair(DiffEntry.ChangeType changeType,
DiffEntry src,
DiffEntry dst,
int score) |
static java.util.List<DiffEntry> |
scan(TreeWalk walk)
Convert the TreeWalk into DiffEntry headers.
|
static java.util.List<DiffEntry> |
scan(TreeWalk walk,
boolean includeTrees)
Convert the TreeWalk into DiffEntry headers, depending on
includeTrees it will add tree objects into result or not. |
static java.util.List<DiffEntry> |
scan(TreeWalk walk,
boolean includeTrees,
TreeFilter[] markTreeFilters)
Convert the TreeWalk into DiffEntry headers, depending on
includeTrees it will add tree objects into result or not. |
java.lang.String |
toString() |
static final AbbreviatedObjectId A_ZERO
public static final java.lang.String DEV_NULL
protected java.lang.String oldPath
protected java.lang.String newPath
protected Attribute diffAttribute
protected FileMode oldMode
protected FileMode newMode
protected DiffEntry.ChangeType changeType
protected int score
changeType
is a copy or rename.protected AbbreviatedObjectId oldId
protected AbbreviatedObjectId newId
private int treeFilterMarks
scan(TreeWalk, boolean, TreeFilter...)
public static java.util.List<DiffEntry> scan(TreeWalk walk) throws java.io.IOException
walk
- the TreeWalk to walk through. Must have exactly two trees.java.io.IOException
- the repository cannot be accessed.java.lang.IllegalArgumentException
- When given TreeWalk doesn't have exactly two trees.public static java.util.List<DiffEntry> scan(TreeWalk walk, boolean includeTrees) throws java.io.IOException
includeTrees
it will add tree objects into result or not.walk
- the TreeWalk to walk through. Must have exactly two trees and
when includeTrees
parameter is true
it can't
be recursive.includeTrees
- include tree objects.java.io.IOException
- the repository cannot be accessed.java.lang.IllegalArgumentException
- when includeTrees
is true and given TreeWalk is
recursive. Or when given TreeWalk doesn't have exactly two
treespublic static java.util.List<DiffEntry> scan(TreeWalk walk, boolean includeTrees, TreeFilter[] markTreeFilters) throws java.io.IOException
includeTrees
it will add tree objects into result or not.walk
- the TreeWalk to walk through. Must have exactly two trees and
when includeTrees
parameter is true
it can't
be recursive.includeTrees
- include tree objects.markTreeFilters
- array of tree filters which will be tested for each entry. If
an entry matches, the entry will later return true when
queried through {isMarked(int)
(with the index from
this passed array).java.io.IOException
- the repository cannot be accessed.java.lang.IllegalArgumentException
- when includeTrees
is true and given TreeWalk is
recursive. Or when given TreeWalk doesn't have exactly two
treesstatic DiffEntry add(java.lang.String path, AnyObjectId id)
static DiffEntry delete(java.lang.String path, AnyObjectId id)
static DiffEntry modify(java.lang.String path)
static java.util.List<DiffEntry> breakModify(DiffEntry entry)
entry
- the DiffEntry to break apart.getChangeType()
on the first entry will return ChangeType.DELETE. Calling it on
the second entry will return ChangeType.ADD.static DiffEntry pair(DiffEntry.ChangeType changeType, DiffEntry src, DiffEntry dst, int score)
public java.lang.String getOldPath()
The meaning of the old name can differ depending on the semantic meaning of this patch:
/dev/null
getNewPath()
public java.lang.String getNewPath()
The meaning of the new name can differ depending on the semantic meaning of this patch:
getOldPath()
/dev/null
public java.lang.String getPath(DiffEntry.Side side)
side
- which path to obtain.public Attribute getDiffAttribute()
Attribute
determining filters to be applied.public FileMode getOldMode()
public FileMode getNewMode()
public FileMode getMode(DiffEntry.Side side)
side
- which mode to obtain.public DiffEntry.ChangeType getChangeType()
getNewPath()
public int getScore()
getOldPath()
and
getNewPath()
if getChangeType()
is
DiffEntry.ChangeType.COPY
or
DiffEntry.ChangeType.RENAME
.public AbbreviatedObjectId getOldId()
index
.public AbbreviatedObjectId getNewId()
index
.public boolean isMarked(int index)
scan(TreeWalk, boolean, TreeFilter...)
. Example:
TreeFilter filterA = ...; TreeFilter filterB = ...; List<DiffEntry> entries = DiffEntry.scan(walk, false, filterA, filterB); DiffEntry entry = entries.get(0); boolean filterAMatched = entry.isMarked(0); boolean filterBMatched = entry.isMarked(1);
Note that 0 corresponds to filterA because it was the first filter that was passed to scan.
To query more than one flag at once, see getTreeFilterMarks()
.
index
- the index of the tree filter to check for (must be between 0
and Integer.SIZE
).public int getTreeFilterMarks()
scan(TreeWalk, boolean, TreeFilter...)
. See
isMarked(int)
to query each mark individually.public AbbreviatedObjectId getId(DiffEntry.Side side)
side
- the side of the id to get.public java.lang.String toString()
toString
in class java.lang.Object