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 classAnInputStreamthat updates aSHA1on every byte read.private static classWe write the patch result to aTemporaryBufferand then useDirCacheCheckout.getContent() to run the result through the CR-LF and smudge filters.private static interfaceSomething that can supply anInputStream. -
Field Summary
FieldsFields inherited from class org.eclipse.jgit.api.GitCommand
repo -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidapply(Repository repository, String path, DirCache cache, File f, FileHeader fh) private voidapplyBinary(Repository repository, String path, File f, FileHeader fh, ApplyCommand.StreamSupplier loader, ObjectId id, DirCacheCheckout.CheckoutMetadata checkOut) private voidapplyText(Repository repository, String path, RawText rt, File f, FileHeader fh, DirCacheCheckout.CheckoutMetadata checkOut) call()private booleancanApplyAt(List<ByteBuffer> hunkLines, List<ByteBuffer> newLines, int line) private voidprivate InputStreamfilterClean(Repository repository, String path, InputStream fromFile, boolean convertCrLf, String filterCommand) private Fileprivate static booleanhasCrLf(FileHeader fileHeader) private ObjectIdprivate voidprivate booleanprivate booleanneedsCrLfConversion(File f, FileHeader fileHeader) setPatch(InputStream in) Set patchprivate ByteBufferslice(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
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
-
getFile
- Throws:
PatchApplyException
-
apply
private void apply(Repository repository, String path, DirCache cache, File f, FileHeader fh) throws IOException, PatchApplyException - Throws:
IOExceptionPatchApplyException
-
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:
PatchApplyExceptionIOException
-
applyBinary
private void applyBinary(Repository repository, String path, File f, FileHeader fh, ApplyCommand.StreamSupplier loader, ObjectId id, DirCacheCheckout.CheckoutMetadata checkOut) throws PatchApplyException, IOException - Throws:
PatchApplyExceptionIOException
-
applyText
private void applyText(Repository repository, String path, RawText rt, File f, FileHeader fh, DirCacheCheckout.CheckoutMetadata checkOut) throws IOException, PatchApplyException - Throws:
IOExceptionPatchApplyException
-
canApplyAt
-
slice
-
isNoNewlineAtEndOfFile
-