* Executes the {@code ApplyCommand} command with all the options and * parameters collected by the setter methods (e.g. * {@link #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. */ @Override public ApplyResult call() throws GitAPIException { checkCallable(); setCallable(false); Patch patch = new Patch(); try (InputStream inStream = in) { patch.parse(inStream); if (!patch.getErrors().isEmpty()) { throw new PatchFormatException(patch.getErrors()); } } catch (IOException e) { throw new PatchApplyException(MessageFormat.format( JGitText.get().patchApplyException, e.getMessage()), e); } ApplyResult r = new ApplyResult(); try { PatchApplier patchApplier = new PatchApplier(repo); Result applyResult = patchApplier.applyPatch(patch); if (!applyResult.getErrors().isEmpty()) { throw new PatchApplyException( MessageFormat.format(JGitText.get().patchApplyException, applyResult.getErrors())); } for (String p : applyResult.getPaths()) { r.addUpdatedFile(new File(repo.getWorkTree(), p)); } } catch (IOException e) { throw new PatchApplyException(MessageFormat.format(JGitText.get().patchApplyException, e.getMessage(), e)); } return r; } }