public class DiffEntry extends 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 |
---|---|
protected DiffEntry.ChangeType |
changeType
General type of change indicated by the patch.
|
static 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 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 String |
oldPath
File name of the old (pre-image).
|
protected int |
score
Similarity score if
changeType is a copy or rename. |
Modifier | Constructor and Description |
---|---|
protected |
DiffEntry()
Create an empty DiffEntry
|
Modifier and Type | Method and Description |
---|---|
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
|
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
|
String |
getOldPath()
Get the old name associated with this file.
|
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...) . |
static List<DiffEntry> |
scan(TreeWalk walk)
Convert the TreeWalk into DiffEntry headers.
|
static 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 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. |
String |
toString() |
public static final String DEV_NULL
protected String oldPath
protected 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
public static List<DiffEntry> scan(TreeWalk walk) throws IOException
walk
- the TreeWalk to walk through. Must have exactly two trees.IOException
- the repository cannot be accessed.IllegalArgumentException
- When given TreeWalk doesn't have exactly two trees.public static List<DiffEntry> scan(TreeWalk walk, boolean includeTrees) throws 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.IOException
- the repository cannot be accessed.IllegalArgumentException
- when includeTrees
is true and given TreeWalk is
recursive. Or when given TreeWalk doesn't have exactly two
treespublic static List<DiffEntry> scan(TreeWalk walk, boolean includeTrees, TreeFilter[] markTreeFilters) throws 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).IOException
- the repository cannot be accessed.IllegalArgumentException
- when includeTrees
is true and given TreeWalk is
recursive. Or when given TreeWalk doesn't have exactly two
treespublic String getOldPath()
The meaning of the old name can differ depending on the semantic meaning of this patch:
/dev/null
getNewPath()
public String getNewPath()
The meaning of the new name can differ depending on the semantic meaning of this patch:
getOldPath()
/dev/null
public 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.Copyright © 2020 Eclipse JGit Project. All rights reserved.