Update to JGit 0.9.3.86-g4c7e100
This version fixes the DiffFormatter to correctly consider inserted blank lines near the end of a file. Change-Id: I67111a39dd3c8214e119ee53da8a12d2b628e172 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -20,7 +20,7 @@ class CharText extends Sequence {
|
||||
private final String content;
|
||||
|
||||
CharText(Text text, int s, int e) {
|
||||
content = text.getLines(s, e, false /* keep LF */);
|
||||
content = text.getString(s, e, false /* keep LF */);
|
||||
}
|
||||
|
||||
char charAt(int idx) {
|
||||
|
||||
@@ -98,13 +98,13 @@ public class PatchFile {
|
||||
if (a == null) {
|
||||
a = load(aTree, entry.getOldName());
|
||||
}
|
||||
return a.getLine(line - 1);
|
||||
return a.getString(line - 1);
|
||||
|
||||
case 1:
|
||||
if (b == null) {
|
||||
b = load(bTree, entry.getNewName());
|
||||
}
|
||||
return b.getLine(line - 1);
|
||||
return b.getString(line - 1);
|
||||
|
||||
default:
|
||||
throw new NoSuchEntityException();
|
||||
|
||||
@@ -287,8 +287,8 @@ public class PatchListCacheImpl implements PatchListCache {
|
||||
Text bText = Text.forCommit(db, reader, bCommit);
|
||||
|
||||
byte[] rawHdr = hdr.toString().getBytes("UTF-8");
|
||||
RawText aRawText = new RawText(cmp, aText.getContent());
|
||||
RawText bRawText = new RawText(cmp, bText.getContent());
|
||||
RawText aRawText = new RawText(aText.getContent());
|
||||
RawText bRawText = new RawText(bText.getContent());
|
||||
EditList edits = MyersDiff.INSTANCE.diff(cmp, aRawText, bRawText);
|
||||
FileHeader fh = new FileHeader(rawHdr, edits, PatchType.UNIFIED);
|
||||
return newEntry(reader, aText, bText, edits, null, null, fh);
|
||||
@@ -555,7 +555,7 @@ public class PatchListCacheImpl implements PatchListCache {
|
||||
|
||||
private static boolean isBlankLineGap(Text a, int b, int e) {
|
||||
for (; b < e; b++) {
|
||||
if (!BLANK_LINE_RE.matcher(a.getLine(b)).matches()) {
|
||||
if (!BLANK_LINE_RE.matcher(a.getString(b)).matches()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -563,7 +563,7 @@ public class PatchListCacheImpl implements PatchListCache {
|
||||
}
|
||||
|
||||
private static boolean isControlBlockStart(Text a, int idx) {
|
||||
final String l = a.getLine(idx);
|
||||
final String l = a.getString(idx);
|
||||
return CONTROL_BLOCK_START_RE.matcher(l).find();
|
||||
}
|
||||
|
||||
|
||||
@@ -152,35 +152,11 @@ public class Text extends RawText {
|
||||
return content;
|
||||
}
|
||||
|
||||
public String getLine(final int i) {
|
||||
return getLines(i, i + 1, true);
|
||||
}
|
||||
|
||||
public String getLines(final int begin, final int end, boolean dropLF) {
|
||||
if (begin == end) {
|
||||
return "";
|
||||
}
|
||||
|
||||
final int s = getLineStart(begin);
|
||||
int e = getLineEnd(end - 1);
|
||||
if (dropLF && content[e - 1] == '\n') {
|
||||
e--;
|
||||
}
|
||||
return decode(s, e);
|
||||
}
|
||||
|
||||
private String decode(final int s, int e) {
|
||||
@Override
|
||||
protected String decode(final int s, int e) {
|
||||
if (charset == null) {
|
||||
charset = charset(content, null);
|
||||
}
|
||||
return RawParseUtils.decode(charset, content, s, e);
|
||||
}
|
||||
|
||||
private int getLineStart(final int i) {
|
||||
return lines.get(i + 1);
|
||||
}
|
||||
|
||||
private int getLineEnd(final int i) {
|
||||
return lines.get(i + 2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user