Package org.eclipse.jgit.api
Class AddCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<DirCache>
-
- org.eclipse.jgit.api.AddCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<DirCache>
public class AddCommand extends GitCommand<DirCache>
A class used to execute aAdd
command. It has setters for all supported options and arguments of this command and acall()
method to finally execute the command. Each instance of this class should only be used for one invocation of the command (means: one call tocall()
)- See Also:
- Git documentation about Add
-
-
Field Summary
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Constructor Description AddCommand(Repository repo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AddCommand
addFilepattern(java.lang.String filepattern)
Add a path to a file/directory whose content should be added.DirCache
call()
Executes theAdd
command.boolean
isUpdate()
AddCommand
setUpdate(boolean update)
AddCommand
setWorkingTreeIterator(WorkingTreeIterator f)
Allow clients to provide their own implementation of a FileTreeIterator-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
AddCommand
public AddCommand(Repository repo)
- Parameters:
repo
-
-
-
Method Detail
-
addFilepattern
public AddCommand addFilepattern(java.lang.String filepattern)
Add a path to a file/directory whose content should be added.A directory name (e.g.
dir
to adddir/file1
anddir/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
public AddCommand setWorkingTreeIterator(WorkingTreeIterator f)
Allow clients to provide their own implementation of a FileTreeIterator- Parameters:
f
-- Returns:
this
-
call
public DirCache call() throws GitAPIException, NoFilepatternException
Executes theAdd
command. 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:
call
in interfacejava.util.concurrent.Callable<DirCache>
- Specified by:
call
in classGitCommand<DirCache>
- Returns:
- the DirCache after Add
- Throws:
GitAPIException
- or subclass thereof when an error occursNoFilepatternException
-
setUpdate
public AddCommand setUpdate(boolean update)
- Parameters:
update
- If set to true, the command only matchesfilepattern
against 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 afilepattern
must exist also if update is set to true as there is no concept of a working directory here.- Returns:
this
-
isUpdate
public boolean isUpdate()
- Returns:
- is the parameter update is set
-
-