Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe01fd3

Browse filesBrowse files
committed
do not produce any diffs if there is not any changes at all
1 parent 97a74c3 commit fe01fd3
Copy full SHA for fe01fd3

File tree

1 file changed

+7
-6
lines changed
Filter options

1 file changed

+7
-6
lines changed

‎src/difflib/DiffUtils.java

Copy file name to clipboardExpand all lines: src/difflib/DiffUtils.java
+7-6Lines changed: 7 additions & 6 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.