Skip to content

Commit 21d111b

Browse files
Don't read the tail if it isn't there
1 parent 1c0daa1 commit 21d111b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/github/difflib/unifieddiff/UnifiedDiffReader.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ private UnifiedDiff parse() throws IOException, UnifiedDiffParserException {
6767
boolean header = true;
6868
String headerTxt = "";
6969
String tailTxt = "";
70+
boolean hasTail = false;
7071
while (READER.ready()) {
7172
String line = READER.readLine();
7273
if (line.matches("--\\s*")) {
74+
hasTail = true;
7375
break;
7476
} else {
7577
LOG.log(Level.INFO, "parsing line {0}", line);
@@ -93,7 +95,8 @@ private UnifiedDiff parse() throws IOException, UnifiedDiffParserException {
9395
while (READER.ready()) {
9496
tailTxt += READER.readLine() + "\n";
9597
}
96-
data.setTailTxt(tailTxt);
98+
if (!tailTxt.isEmpty() || hasTail)
99+
data.setTailTxt(tailTxt);
97100

98101
return data;
99102
}

0 commit comments

Comments
 (0)