Source:
private boolean contentMerge(CanonicalTreeParser base, CanonicalTreeParser ours, CanonicalTreeParser theirs) throws FileNotFoundException, IllegalStateException, IOException { MergeFormatter fmt = new MergeFormatter(); RawText baseText = (base == null) ? emptyText : getRawText( base.getEntryObjectId(), db); MergeResult<RawText> result = MergeAlgorithm.merge( RawTextComparator.DEFAULT, baseText, getRawText(ours.getEntryObjectId(), db), getRawText(theirs.getEntryObjectId(), db)); File of = null; FileOutputStream fos; if (!inCore) { File workTree = db.getWorkTree(); if (workTree == null) throw new UnsupportedOperationException(); of = new File(workTree, tw.getPathString()); fos = new FileOutputStream(of); try { fmt.formatMerge(fos, result, Arrays.asList(commitNames), Constants.CHARACTER_ENCODING); } finally { fos.close(); } } else if (!result.containsConflicts()) { of = File.createTempFile("merge_", "_temp", null); fos = new FileOutputStream(of); try { fmt.formatMerge(fos, result, Arrays.asList(commitNames), Constants.CHARACTER_ENCODING); } finally { fos.close(); } } if (result.containsConflicts()) { add(tw.getRawPath(), base, DirCacheEntry.STAGE_1); add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2); add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3); mergeResults.put(tw.getPathString(), result); return false; } else { DirCacheEntry dce = new DirCacheEntry(tw.getPathString()); dce.setFileMode(tw.getFileMode(0)); dce.setLastModified(of.lastModified()); dce.setLength((int) of.length()); InputStream is = new FileInputStream(of); try { dce.setObjectId(oi.insert(Constants.OBJ_BLOB, of.length(), is)); } finally { is.close(); if (inCore) of.delete(); } builder.add(dce); return true; } }

Target:
private boolean contentMerge(CanonicalTreeParser base, CanonicalTreeParser ours, CanonicalTreeParser theirs) throws FileNotFoundException, IllegalStateException, IOException { MergeFormatter fmt = new MergeFormatter(); RawText baseText = base == null ? RawText.EMPTY_TEXT : getRawText( base.getEntryObjectId(), db); MergeResult<RawText> result = MergeAlgorithm.merge( RawTextComparator.DEFAULT, baseText, getRawText(ours.getEntryObjectId(), db), getRawText(theirs.getEntryObjectId(), db)); File of = null; FileOutputStream fos; if (!inCore) { File workTree = db.getWorkTree(); if (workTree == null) throw new UnsupportedOperationException(); of = new File(workTree, tw.getPathString()); fos = new FileOutputStream(of); try { fmt.formatMerge(fos, result, Arrays.asList(commitNames), Constants.CHARACTER_ENCODING); } finally { fos.close(); } } else if (!result.containsConflicts()) { of = File.createTempFile("merge_", "_temp", null); fos = new FileOutputStream(of); try { fmt.formatMerge(fos, result, Arrays.asList(commitNames), Constants.CHARACTER_ENCODING); } finally { fos.close(); } } if (result.containsConflicts()) { add(tw.getRawPath(), base, DirCacheEntry.STAGE_1); add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2); add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3); mergeResults.put(tw.getPathString(), result); return false; } else { DirCacheEntry dce = new DirCacheEntry(tw.getPathString()); dce.setFileMode(tw.getFileMode(0)); dce.setLastModified(of.lastModified()); dce.setLength((int) of.length()); InputStream is = new FileInputStream(of); try { dce.setObjectId(oi.insert(Constants.OBJ_BLOB, of.length(), is)); } finally { is.close(); if (inCore) of.delete(); } builder.add(dce); return true; } }