A class used to execute a
Add command. It has setters for all
supported options and arguments of this command and a call() method
to finally execute the command. Each instance of this class should only be
used for one invocation of the command (means: one call to call())- See Also:
-
Field Summary
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddFilepattern(String filepattern) Add a path to a file/directory whose content should be added.call()booleanTells whether the command will renormalize by re-applying the "clean" process to tracked files.booleanisUpdate()Whether to only match against already tracked filessetRenormalize(boolean renormalize) Defines whether the command will renormalize by re-applying the "clean" process to tracked files.setUpdate(boolean update) Set whether to only match against already tracked filesAllow clients to provide their own implementation of a FileTreeIteratorMethods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Constructor Details
-
AddCommand
Constructor for AddCommand- Parameters:
repo- theRepository
-
-
Method Details
-
addFilepattern
Add a path to a file/directory whose content should be added.A directory name (e.g.
dirto adddir/file1anddir/file2) can also be given to add all files in the directory, recursively. Fileglobs (e.g. *.c) are not yet supported.- Parameters:
filepattern- repository-relative path of file/directory to add (with/as separator)- Returns:
this
-
setWorkingTreeIterator
Allow clients to provide their own implementation of a FileTreeIterator- Parameters:
f- aWorkingTreeIteratorobject.- Returns:
this
-
call
Execute the command
Executes the
Addcommand. Each instance of this class should only be used for one invocation of the command. Don't call this method twice on an instance.- Specified by:
callin interfaceCallable<DirCache>- Specified by:
callin classGitCommand<DirCache>- Throws:
GitAPIExceptionNoFilepatternException
-
setUpdate
Set whether to only match against already tracked files- Parameters:
update- If set to true, the command only matchesfilepatternagainst already tracked files in the index rather than the working tree. That means that it will never stage new files, but that it will stage modified new contents of tracked files and that it will remove files from the index if the corresponding files in the working tree have been removed. In contrast to the git command line afilepatternmust exist also if update is set to true as there is no concept of a working directory here.- Returns:
this
-
isUpdate
public boolean isUpdate()Whether to only match against already tracked files- Returns:
- whether to only match against already tracked files
-
setRenormalize
Defines whether the command will renormalize by re-applying the "clean" process to tracked files.This does not automatically call
setUpdate(boolean).- Parameters:
renormalize- whether to renormalize tracked files- Returns:
this- Since:
- 6.6
-
isRenormalize
public boolean isRenormalize()Tells whether the command will renormalize by re-applying the "clean" process to tracked files.For legacy reasons, this is
trueby default.This setting is independent of
isUpdate(). In C git, command-line option --renormalize implies --update.- Returns:
- whether files will be renormalized
- Since:
- 6.6
-