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 class
ApplyCommand.Result
A 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.InputStream
in
-
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 void
apply(java.io.File f, FileHeader fh)
ApplyResult
call()
private boolean
canApplyAt(java.util.List<java.lang.String> hunkLines, java.util.List<java.lang.String> newLines, int line)
private java.io.File
getFile(java.lang.String path, boolean create, FileModeCache directoryCache)
private static boolean
isChanged(java.util.List<java.lang.String> ol, java.util.List<java.lang.String> nl)
private boolean
isNoNewlineAtEndOfFile(FileHeader fh)
ApplyCommand
setPatch(java.io.InputStream in)
Set patchprivate boolean
validGitPath(java.lang.String path)
private boolean
verifyExistence(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
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 interfacejava.util.concurrent.Callable<ApplyResult>
- Specified by:
call
in classGitCommand<ApplyResult>
- Throws:
GitAPIException
PatchFormatException
PatchApplyException
-
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.IOException
PatchApplyException
-
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)
-
-