// We have to cache the bytes because diff reads the stream twice.. why.. who knows.
byte[] oData = ByteStreams.toByteArray(original);
byte[] cData = ByteStreams.toByteArray(changed);
Diff diff = Diff.diff(new InputStreamReader(new ByteArrayInputStream(oData), Charsets.UTF_8), new InputStreamReader(new ByteArrayInputStream(cData), Charsets.UTF_8), false);
if (!relative.startsWith("/"))
relative = "/" + relative;
if (!diff.isEmpty())
{
String unidiff = diff.toUnifiedDiff(originalPrefix + relative, changedPrefix + relative,
new InputStreamReader(new ByteArrayInputStream(oData), Charsets.UTF_8),
new InputStreamReader(new ByteArrayInputStream(cData), Charsets.UTF_8), 3);
unidiff = unidiff.replace("\r\n", "\n"); //Normalize lines
unidiff = unidiff.replace("\n" + Hunk.ENDING_NEWLINE + "\n", "\n"); //We give 0 shits about this.