Package org.eclipse.jgit.api
Class ApplyCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<ApplyResult>
-
- org.eclipse.jgit.api.ApplyCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<ApplyResult>
public class ApplyCommand extends GitCommand<ApplyResult>
Apply a patch to files and/or to the index.- Since:
- 2.0
- See Also:
- Git documentation about apply
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classApplyCommand.ResultA wrapper for returning both the applied tree ID and the applied files list, as well as file specific errors.
-
Field Summary
Fields Modifier and Type Field Description private java.io.InputStreamin-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Constructor Description ApplyCommand(Repository repo)Constructs the command if the patch is to be applied to the index.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidapply(java.io.File f, FileHeader fh)ApplyResultcall()private booleancanApplyAt(java.util.List<java.lang.String> hunkLines, java.util.List<java.lang.String> newLines, int line)private java.io.FilegetFile(java.lang.String path, boolean create, FileModeCache directoryCache)private static booleanisChanged(java.util.List<java.lang.String> ol, java.util.List<java.lang.String> nl)private booleanisNoNewlineAtEndOfFile(FileHeader fh)ApplyCommandsetPatch(java.io.InputStream in)Set patchprivate booleanvalidGitPath(java.lang.String path)private booleanverifyExistence(FileHeader fh, java.io.File src, java.io.File dest, ApplyCommand.Result result)-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
ApplyCommand
ApplyCommand(Repository repo)
Constructs the command if the patch is to be applied to the index.- Parameters:
repo-
-
-
Method Detail
-
setPatch
public ApplyCommand setPatch(java.io.InputStream in)
Set patch- Parameters:
in- the patch to apply- Returns:
- this instance
-
call
public ApplyResult call() throws GitAPIException, PatchFormatException, PatchApplyException
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 interfacejava.util.concurrent.Callable<ApplyResult>- Specified by:
callin classGitCommand<ApplyResult>- Throws:
GitAPIExceptionPatchFormatExceptionPatchApplyException
-
verifyExistence
private boolean verifyExistence(FileHeader fh, java.io.File src, java.io.File dest, ApplyCommand.Result result) throws java.io.IOException
- Throws:
java.io.IOException
-
validGitPath
private boolean validGitPath(java.lang.String path)
-
getFile
private java.io.File getFile(java.lang.String path, boolean create, FileModeCache directoryCache) throws PatchApplyException- Throws:
PatchApplyException
-
apply
private void apply(java.io.File f, FileHeader fh) throws java.io.IOException, PatchApplyException- Parameters:
f-fh-- Throws:
java.io.IOExceptionPatchApplyException
-
canApplyAt
private boolean canApplyAt(java.util.List<java.lang.String> hunkLines, java.util.List<java.lang.String> newLines, int line)
-
isChanged
private static boolean isChanged(java.util.List<java.lang.String> ol, java.util.List<java.lang.String> nl)
-
isNoNewlineAtEndOfFile
private boolean isNoNewlineAtEndOfFile(FileHeader fh)
-
-