Class Status


  • public class Status
    extends java.lang.Object
    A class telling where the working-tree, the index and the current HEAD differ from each other. Collections are exposed containing the paths of the modified files. E.g. to find out which files are dirty in the working tree (modified but not added) you would inspect the collection returned by getModified().

    The same path can be returned by multiple getters. E.g. if a modification has been added to the index and afterwards the corresponding working tree file is again modified this path will be returned by getModified() and getChanged()

    • Constructor Summary

      Constructors 
      Constructor Description
      Status​(IndexDiff diff)
      Constructor for Status.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Set<java.lang.String> getAdded()
      Get files added to the index
      java.util.Set<java.lang.String> getChanged()
      Get changed files from HEAD to index
      java.util.Set<java.lang.String> getConflicting()
      Get conflicting files
      java.util.Map<java.lang.String,​IndexDiff.StageState> getConflictingStageState()
      Get StageState of conflicting files
      java.util.Set<java.lang.String> getIgnoredNotInIndex()
      Get ignored files which are not in the index
      java.util.Set<java.lang.String> getMissing()
      Get missing files
      java.util.Set<java.lang.String> getModified()
      Get modified files relative to the index
      java.util.Set<java.lang.String> getRemoved()
      Get removed files
      java.util.Set<java.lang.String> getUncommittedChanges()
      Get uncommitted changes, i.e.
      java.util.Set<java.lang.String> getUntracked()
      Get untracked files
      java.util.Set<java.lang.String> getUntrackedFolders()
      Get untracked folders
      boolean hasUncommittedChanges()
      Whether there are uncommitted changes
      boolean isClean()
      Whether the status is clean
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • clean

        private final boolean clean
      • hasUncommittedChanges

        private final boolean hasUncommittedChanges
    • Constructor Detail

      • Status

        public Status​(IndexDiff diff)
        Constructor for Status.
        Parameters:
        diff - the IndexDiff having the status
    • Method Detail

      • isClean

        public boolean isClean()
        Whether the status is clean
        Returns:
        true if no differences exist between the working-tree, the index, and the current HEAD, false if differences do exist
      • hasUncommittedChanges

        public boolean hasUncommittedChanges()
        Whether there are uncommitted changes
        Returns:
        true if any tracked file is changed
        Since:
        3.2
      • getAdded

        public java.util.Set<java.lang.String> getAdded()
        Get files added to the index
        Returns:
        list of files added to the index, not in HEAD (e.g. what you get if you call git add ... on a newly created file)
      • getChanged

        public java.util.Set<java.lang.String> getChanged()
        Get changed files from HEAD to index
        Returns:
        list of files changed from HEAD to index (e.g. what you get if you modify an existing file and call 'git add ...' on it)
      • getRemoved

        public java.util.Set<java.lang.String> getRemoved()
        Get removed files
        Returns:
        list of files removed from index, but in HEAD (e.g. what you get if you call 'git rm ...' on a existing file)
      • getMissing

        public java.util.Set<java.lang.String> getMissing()
        Get missing files
        Returns:
        list of files in index, but not filesystem (e.g. what you get if you call 'rm ...' on a existing file)
      • getModified

        public java.util.Set<java.lang.String> getModified()
        Get modified files relative to the index
        Returns:
        list of files modified on disk relative to the index (e.g. what you get if you modify an existing file without adding it to the index)
      • getUntracked

        public java.util.Set<java.lang.String> getUntracked()
        Get untracked files
        Returns:
        list of files that are not ignored, and not in the index. (e.g. what you get if you create a new file without adding it to the index)
      • getUntrackedFolders

        public java.util.Set<java.lang.String> getUntrackedFolders()
        Get untracked folders
        Returns:
        set of directories that are not ignored, and not in the index.
      • getConflicting

        public java.util.Set<java.lang.String> getConflicting()
        Get conflicting files
        Returns:
        list of files that are in conflict. (e.g what you get if you modify file that was modified by someone else in the meantime)
      • getConflictingStageState

        public java.util.Map<java.lang.String,​IndexDiff.StageState> getConflictingStageState()
        Get StageState of conflicting files
        Returns:
        a map from conflicting path to its IndexDiff.StageState.
        Since:
        3.0
      • getIgnoredNotInIndex

        public java.util.Set<java.lang.String> getIgnoredNotInIndex()
        Get ignored files which are not in the index
        Returns:
        set of files and folders that are ignored and not in the index.
      • getUncommittedChanges

        public java.util.Set<java.lang.String> getUncommittedChanges()
        Get uncommitted changes, i.e. all files changed in the index or working tree
        Returns:
        set of files and folders that are known to the repo and changed either in the index or in the working tree.
        Since:
        3.2