Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit e00d2a1

Browse files
do not produce any diffs if there is not any changes at all
git-svn-id: http://java-diff-utils.googlecode.com/svn/trunk@47 d8d7d024-a22d-11de-b755-fd640f38fa9d
1 parent 3f9cc21 commit e00d2a1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/difflib/DiffUtils.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ public static Patch parseUnifiedDiff(List<String> diff) {
182182
*/
183183
public static List<String> generateUnifiedDiff(String original, String revised,
184184
List<String> originalLines, Patch patch, int contextSize) {
185-
List<String> ret = new ArrayList<String>();
186-
ret.add("--- " + original);
187-
ret.add("+++ " + revised);
188-
189185
if (!patch.getDeltas().isEmpty()) {
186+
List<String> ret = new ArrayList<String>();
187+
ret.add("--- " + original);
188+
ret.add("+++ " + revised);
189+
190190
List<Delta> patchDeltas = new ArrayList<Delta>(patch.getDeltas());
191191

192192
// code outside the if block also works for single-delta issues.
@@ -220,8 +220,9 @@ public static List<String> generateUnifiedDiff(String original, String revised,
220220
// don't forget to process the last set of Deltas
221221
List<String> curBlock = processDeltas(originalLines, deltas, contextSize);
222222
ret.addAll(curBlock);
223+
return ret;
223224
}
224-
return ret;
225+
return new ArrayList<String>();
225226
}
226227

227228
/**
@@ -260,7 +261,7 @@ private static List<String> processDeltas(List<String> origLines, List<Delta> de
260261
}
261262

262263
// output the context before the first Delta
263-
for (line = contextStart; line < curDelta.getOriginal().getPosition(); line++) { //
264+
for (line = contextStart; line < curDelta.getOriginal().getPosition(); line++) { //
264265
buffer.add(" " + origLines.get(line));
265266
origTotal++;
266267
revTotal++;

0 commit comments

Comments
 (0)