Source:
<code>public void execute(IProgressMonitor monitor) throws CoreException { EclipseGitProgressTransformer gitMonitor; if (monitor == null) gitMonitor = new EclipseGitProgressTransformer( new NullProgressMonitor()); else gitMonitor = new EclipseGitProgressTransformer(monitor); final StringBuilder sb = new StringBuilder(); final DiffFormatter diffFmt = new DiffFormatter( new ByteArrayOutputStream() { @Override public synchronized void write(byte[] b, int off, int len) { super.write(b, off, len); if (currentEncoding == null) sb.append(toString()); else try { sb.append(toString(currentEncoding)); } catch (UnsupportedEncodingException e) { sb.append(toString()); } reset(); } }); diffFmt.setProgressMonitor(gitMonitor); diffFmt.setContext(contextLines); if (useGitFormat) writeGitPatchHeader(sb); diffFmt.setRepository(repository); try { if (commit != null) { RevCommit[] parents = commit.getParents(); if (parents.length > 1) throw new IllegalStateException( <START> "Cannot create patch for merge commit"); END> if (parents.length == 0) throw new IllegalStateException( "Cannot create patch for first commit"); List<DiffEntry> diffs = diffFmt.scan(parents[0].getId(),commit.getId()); for (DiffEntry ent : diffs) { String path; if (ChangeType.DELETE.equals(ent.getChangeType())) path = ent.getOldPath(); else path = ent.getNewPath(); currentEncoding = CompareCoreUtils.getResourceEncoding(repository, path); diffFmt.format(ent); } } else { diffFmt.format( new DirCacheIterator(repository.readDirCache()), new FileTreeIterator(repository)); } } catch (IOException e) { Activator.logError("Patch file could not be written", e); } patchContent = sb.toString(); if (patchContent.endsWith("\n")) patchContent = patchContent.substring(0, patchContent.length() - 1); }</code><technical_language>externalize error messages</technical_language>

Target:
public void execute(IProgressMonitor monitor) throws CoreException { EclipseGitProgressTransformer gitMonitor; if (monitor == null) gitMonitor = new EclipseGitProgressTransformer( new NullProgressMonitor()); else gitMonitor = new EclipseGitProgressTransformer(monitor); final StringBuilder sb = new StringBuilder(); final DiffFormatter diffFmt = new DiffFormatter( new ByteArrayOutputStream() { @Override public synchronized void write(byte[] b, int off, int len) { super.write(b, off, len); if (currentEncoding == null) sb.append(toString()); else try { sb.append(toString(currentEncoding)); } catch (UnsupportedEncodingException e) { sb.append(toString()); } reset(); } }); diffFmt.setProgressMonitor(gitMonitor); diffFmt.setContext(contextLines); if (useGitFormat) writeGitPatchHeader(sb); diffFmt.setRepository(repository); try { if (commit != null) { RevCommit[] parents = commit.getParents(); if (parents.length > 1) throw new IllegalStateException( CoreText.CreatePatchOperation_cannotCreatePatchForMergeCommit); if (parents.length == 0) throw new IllegalStateException( CoreText.CreatePatchOperation_cannotCreatePatchForFirstCommit); List<DiffEntry> diffs = diffFmt.scan(parents[0].getId(),commit.getId()); for (DiffEntry ent : diffs) { String path; if (ChangeType.DELETE.equals(ent.getChangeType())) path = ent.getOldPath(); else path = ent.getNewPath(); currentEncoding = CompareCoreUtils.getResourceEncoding(repository, path); diffFmt.format(ent); } } else { diffFmt.format( new DirCacheIterator(repository.readDirCache()), new FileTreeIterator(repository)); } } catch (IOException e) { Activator.logError(CoreText.CreatePatchOperation_patchFileCouldNotBeWritten, e); } patchContent = sb.toString(); if (patchContent.endsWith("\n")) patchContent = patchContent.substring(0, patchContent.length() - 1); }