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 classA 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 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 voidapply(File f, FileHeader fh) call()private booleancanApplyAt(List<String> hunkLines, List<String> newLines, int line) private FilegetFile(String path, boolean create, FileModeCache directoryCache) private static booleanprivate booleansetPatch(InputStream in) Set patchprivate booleanvalidGitPath(String path) private booleanverifyExistence(FileHeader fh, File src, File dest, ApplyCommand.Result result) Methods inherited from class 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
ApplyCommandcommand 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:
callin interfaceCallable<ApplyResult>- Specified by:
callin classGitCommand<ApplyResult>- Throws:
GitAPIExceptionPatchFormatExceptionPatchApplyException
-
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:
IOExceptionPatchApplyException
-
canApplyAt
-
isChanged
-
isNoNewlineAtEndOfFile
-