public class IndexDiff
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
IndexDiff.ProgressReportingFilter |
static class |
IndexDiff.StageState
Represents the state of the index for a certain path regarding the stages
- which stages exist for a path and which not (base, ours, theirs).
|
static interface |
IndexDiff.WorkingTreeIteratorFactory
A factory to producing WorkingTreeIterators
|
Modifier and Type | Field and Description |
---|---|
private java.util.Set<java.lang.String> |
added |
private java.util.Set<java.lang.String> |
assumeUnchanged |
private java.util.Set<java.lang.String> |
changed |
private java.util.Map<java.lang.String,IndexDiff.StageState> |
conflicts |
private DirCache |
dirCache |
private java.util.Map<FileMode,java.util.Set<java.lang.String>> |
fileModes |
private TreeFilter |
filter |
private java.util.Set<java.lang.String> |
ignored |
private SubmoduleWalk.IgnoreSubmoduleMode |
ignoreSubmoduleMode |
private static int |
INDEX |
private IndexDiffFilter |
indexDiffFilter |
private WorkingTreeIterator |
initialWorkingTreeIterator |
private java.util.Set<java.lang.String> |
missing |
private java.util.Set<java.lang.String> |
missingSubmodules |
private java.util.Set<java.lang.String> |
modified |
private java.util.Set<java.lang.String> |
removed |
private Repository |
repository |
private java.util.Map<java.lang.String,IndexDiff> |
submoduleIndexDiffs |
private AnyObjectId |
tree |
private static int |
TREE |
private java.util.Set<java.lang.String> |
untracked |
private static int |
WORKDIR |
private IndexDiff.WorkingTreeIteratorFactory |
wTreeIt |
Constructor and Description |
---|
IndexDiff(Repository repository,
ObjectId objectId,
WorkingTreeIterator workingTreeIterator)
Construct an Indexdiff
|
IndexDiff(Repository repository,
java.lang.String revstr,
WorkingTreeIterator workingTreeIterator)
Construct an IndexDiff
|
Modifier and Type | Method and Description |
---|---|
private void |
addConflict(java.lang.String path,
int stage) |
boolean |
diff()
Run the diff operation.
|
boolean |
diff(ProgressMonitor monitor,
int estWorkTreeSize,
int estIndexSize,
java.lang.String title)
Run the diff operation.
|
java.util.Set<java.lang.String> |
getAdded()
Get list of files added to the index, not in the tree
|
java.util.Set<java.lang.String> |
getAssumeUnchanged()
Get list of files with the flag assume-unchanged
|
java.util.Set<java.lang.String> |
getChanged()
Get list of files changed from tree to index
|
java.util.Set<java.lang.String> |
getConflicting()
Get list of files that are in conflict, corresponds to the keys of
getConflictingStageStates() |
java.util.Map<java.lang.String,IndexDiff.StageState> |
getConflictingStageStates()
Get the map from each path of
getConflicting() to its
corresponding IndexDiff.StageState |
java.util.Set<java.lang.String> |
getIgnoredNotInIndex()
The method returns the list of ignored files and folders.
|
FileMode |
getIndexMode(java.lang.String path)
Get the file mode of the given path in the index
|
java.util.Set<java.lang.String> |
getMissing()
Get list of files in index, but not filesystem
|
java.util.Set<java.lang.String> |
getModified()
Get list of files modified on disk relative to the index
|
java.util.Set<java.lang.String> |
getPathsWithIndexMode(FileMode mode)
Get the list of paths that IndexDiff has detected to differ and have the
given file mode
|
java.util.Set<java.lang.String> |
getRemoved()
Get list of files removed from index, but in tree
|
java.util.Set<java.lang.String> |
getUntracked()
Get list of files that are not ignored, and not in the index.
|
java.util.Set<java.lang.String> |
getUntrackedFolders()
Get list of folders containing only untracked files/folders
|
private boolean |
hasFiles(java.io.File directory) |
private boolean |
isEntryGitLink(AbstractTreeIterator ti) |
private void |
recordFileMode(java.lang.String path,
FileMode mode) |
void |
setFilter(TreeFilter filter)
Sets a filter.
|
void |
setIgnoreSubmoduleMode(SubmoduleWalk.IgnoreSubmoduleMode mode)
Defines how modifications in submodules are treated
|
void |
setWorkingTreeItFactory(IndexDiff.WorkingTreeIteratorFactory wTreeIt)
Allows higher layers to set the factory for WorkingTreeIterators.
|
private static final int TREE
private static final int INDEX
private static final int WORKDIR
private final Repository repository
private final AnyObjectId tree
private TreeFilter filter
private final WorkingTreeIterator initialWorkingTreeIterator
private java.util.Set<java.lang.String> added
private java.util.Set<java.lang.String> changed
private java.util.Set<java.lang.String> removed
private java.util.Set<java.lang.String> missing
private java.util.Set<java.lang.String> missingSubmodules
private java.util.Set<java.lang.String> modified
private java.util.Set<java.lang.String> untracked
private java.util.Map<java.lang.String,IndexDiff.StageState> conflicts
private java.util.Set<java.lang.String> ignored
private java.util.Set<java.lang.String> assumeUnchanged
private DirCache dirCache
private IndexDiffFilter indexDiffFilter
private java.util.Map<java.lang.String,IndexDiff> submoduleIndexDiffs
private SubmoduleWalk.IgnoreSubmoduleMode ignoreSubmoduleMode
private java.util.Map<FileMode,java.util.Set<java.lang.String>> fileModes
private IndexDiff.WorkingTreeIteratorFactory wTreeIt
public IndexDiff(Repository repository, java.lang.String revstr, WorkingTreeIterator workingTreeIterator) throws java.io.IOException
repository
- a Repository
object.revstr
- symbolic name e.g. HEAD An EmptyTreeIterator is used if
revstr
cannot be resolved.workingTreeIterator
- iterator for working directoryjava.io.IOException
public IndexDiff(Repository repository, ObjectId objectId, WorkingTreeIterator workingTreeIterator) throws java.io.IOException
repository
- a Repository
object.objectId
- tree id. If null, an EmptyTreeIterator is used.workingTreeIterator
- iterator for working directoryjava.io.IOException
public void setIgnoreSubmoduleMode(SubmoduleWalk.IgnoreSubmoduleMode mode)
mode
- defines how modifications in submodules are treatedpublic void setWorkingTreeItFactory(IndexDiff.WorkingTreeIteratorFactory wTreeIt)
wTreeIt
- public void setFilter(TreeFilter filter)
filter
- a TreeFilter
object.public boolean diff() throws java.io.IOException
diff(ProgressMonitor, int, int, String)
if a progress
monitor is required.java.io.IOException
public boolean diff(ProgressMonitor monitor, int estWorkTreeSize, int estIndexSize, java.lang.String title) throws java.io.IOException
The operation may be aborted by the progress monitor. In that event it
will report what was found before the cancel operation was detected.
Callers should ignore the result if monitor.isCancelled() is true. If a
progress monitor is not needed, callers should use diff()
instead. Progress reporting is crude and approximate and only intended
for informing the user.
monitor
- for reporting progress, may be nullestWorkTreeSize
- number or estimated files in the working treeestIndexSize
- number of estimated entries in the cachetitle
- a String
object.java.io.IOException
private boolean hasFiles(java.io.File directory)
private void recordFileMode(java.lang.String path, FileMode mode)
private boolean isEntryGitLink(AbstractTreeIterator ti)
private void addConflict(java.lang.String path, int stage)
public java.util.Set<java.lang.String> getAdded()
public java.util.Set<java.lang.String> getChanged()
public java.util.Set<java.lang.String> getRemoved()
public java.util.Set<java.lang.String> getMissing()
public java.util.Set<java.lang.String> getModified()
public java.util.Set<java.lang.String> getUntracked()
public java.util.Set<java.lang.String> getConflicting()
getConflictingStageStates()
getConflictingStageStates()
public java.util.Map<java.lang.String,IndexDiff.StageState> getConflictingStageStates()
getConflicting()
to its
corresponding IndexDiff.StageState
getConflicting()
to its
corresponding IndexDiff.StageState
public java.util.Set<java.lang.String> getIgnoredNotInIndex()
public java.util.Set<java.lang.String> getAssumeUnchanged()
public java.util.Set<java.lang.String> getUntrackedFolders()
public FileMode getIndexMode(java.lang.String path)
path
- a String
object.public java.util.Set<java.lang.String> getPathsWithIndexMode(FileMode mode)
mode
- a FileMode
object.