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
-
-
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)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 patch-
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
-
getFile
private java.io.File getFile(java.lang.String path, boolean create) 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)
-
-