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 TypeClassDescriptionprivate static class
AnInputStream
that updates aSHA1
on every byte read.private static class
We write the patch result to aTemporaryBuffer
and then useDirCacheCheckout
.getContent() to run the result through the CR-LF and smudge filters.private static interface
Something that can supply anInputStream
. -
Field Summary
FieldsFields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
apply
(Repository repository, String path, DirCache cache, File f, FileHeader fh) private void
applyBinary
(Repository repository, String path, File f, FileHeader fh, ApplyCommand.StreamSupplier loader, ObjectId id, DirCacheCheckout.CheckoutMetadata checkOut) private void
applyText
(Repository repository, String path, RawText rt, File f, FileHeader fh, DirCacheCheckout.CheckoutMetadata checkOut) call()
private boolean
canApplyAt
(List<ByteBuffer> hunkLines, List<ByteBuffer> newLines, int line) private void
private InputStream
filterClean
(Repository repository, String path, InputStream fromFile, boolean convertCrLf, String filterCommand) private File
private static boolean
hasCrLf
(FileHeader fileHeader) private ObjectId
private void
private boolean
private boolean
needsCrLfConversion
(File f, FileHeader fileHeader) setPatch
(InputStream in) Set patchprivate ByteBuffer
slice
(ByteBuffer b, int off) Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Field Details
-
in
-
-
Constructor Details
-
ApplyCommand
ApplyCommand(Repository repo) Constructs the command.- 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
-
getFile
- Throws:
PatchApplyException
-
apply
private void apply(Repository repository, String path, DirCache cache, File f, FileHeader fh) throws IOException, PatchApplyException - Throws:
IOException
PatchApplyException
-
needsCrLfConversion
- Throws:
IOException
-
hasCrLf
-
filterClean
private InputStream filterClean(Repository repository, String path, InputStream fromFile, boolean convertCrLf, String filterCommand) throws IOException - Throws:
IOException
-
initHash
-
hash
- Throws:
IOException
-
checkOid
private void checkOid(ObjectId baseId, ObjectId id, DiffEntry.ChangeType type, File f, String path) throws PatchApplyException, IOException - Throws:
PatchApplyException
IOException
-
applyBinary
private void applyBinary(Repository repository, String path, File f, FileHeader fh, ApplyCommand.StreamSupplier loader, ObjectId id, DirCacheCheckout.CheckoutMetadata checkOut) throws PatchApplyException, IOException - Throws:
PatchApplyException
IOException
-
applyText
private void applyText(Repository repository, String path, RawText rt, File f, FileHeader fh, DirCacheCheckout.CheckoutMetadata checkOut) throws IOException, PatchApplyException - Throws:
IOException
PatchApplyException
-
canApplyAt
-
slice
-
isNoNewlineAtEndOfFile
-