Package org.eclipse.jgit.api
Class ApplyCommand
- All Implemented Interfaces:
Callable<ApplyResult>
Apply a patch to files and/or to the index.
- Since:
- 2.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A wrapper for returning both the applied tree ID and the applied files list, as well as file specific errors. -
Field Summary
FieldsFields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
Constructor Summary
ConstructorsConstructorDescriptionApplyCommand
(Repository repo) Constructs the command if the patch is to be applied to the index. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
apply
(File f, FileHeader fh) call()
private boolean
canApplyAt
(List<String> hunkLines, List<String> newLines, int line) private File
getFile
(String path, boolean create, FileModeCache directoryCache) private static boolean
private boolean
setPatch
(InputStream in) Set patchprivate boolean
validGitPath
(String path) private boolean
verifyExistence
(FileHeader fh, File src, File dest, ApplyCommand.Result result) Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Field Details
-
in
-
-
Constructor Details
-
ApplyCommand
ApplyCommand(Repository repo) Constructs the command if the patch is to be applied to the index.- Parameters:
repo
-
-
-
Method Details
-
setPatch
Set patch- Parameters:
in
- the patch to apply- Returns:
- this instance
-
call
Execute the command
Executes the
ApplyCommand
command with all the options and parameters collected by the setter methods (e.g.setPatch(InputStream)
of this class. 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 interfaceCallable<ApplyResult>
- Specified by:
call
in classGitCommand<ApplyResult>
- Throws:
GitAPIException
PatchFormatException
PatchApplyException
-
verifyExistence
private boolean verifyExistence(FileHeader fh, File src, File dest, ApplyCommand.Result result) throws IOException - Throws:
IOException
-
validGitPath
-
getFile
private File getFile(String path, boolean create, FileModeCache directoryCache) throws PatchApplyException - Throws:
PatchApplyException
-
apply
- Parameters:
f
-fh
-- Throws:
IOException
PatchApplyException
-
canApplyAt
-
isChanged
-
isNoNewlineAtEndOfFile
-