Fix ApplyCommand which doesn't work if patch adds empty file
Bug: 548219 Change-Id: Ibb32132a38e54508a24489322da58ddfd80a1d9a Signed-off-by: Anton Khodos <khodosanton@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
8c7f1a699a
commit
5e44bfa3ad
Binary file not shown.
|
@ -110,6 +110,16 @@ public void testAddA2() throws Exception {
|
||||||
b.getString(0, b.size(), false));
|
b.getString(0, b.size(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddA3() throws Exception {
|
||||||
|
ApplyResult result = init("A3", false, true);
|
||||||
|
assertEquals(1, result.getUpdatedFiles().size());
|
||||||
|
assertEquals(new File(db.getWorkTree(), "A3"),
|
||||||
|
result.getUpdatedFiles().get(0));
|
||||||
|
checkFile(new File(db.getWorkTree(), "A3"),
|
||||||
|
b.getString(0, b.size(), false));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddA1Sub() throws Exception {
|
public void testAddA1Sub() throws Exception {
|
||||||
ApplyResult result = init("A1_sub", false, false);
|
ApplyResult result = init("A1_sub", false, false);
|
||||||
|
|
|
@ -279,9 +279,13 @@ private static boolean isChanged(List<String> ol, List<String> nl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNoNewlineAtEndOfFile(FileHeader fh) {
|
private boolean isNoNewlineAtEndOfFile(FileHeader fh) {
|
||||||
HunkHeader lastHunk = fh.getHunks().get(fh.getHunks().size() - 1);
|
List<? extends HunkHeader> hunks = fh.getHunks();
|
||||||
|
if (hunks == null || hunks.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
HunkHeader lastHunk = hunks.get(hunks.size() - 1);
|
||||||
RawText lhrt = new RawText(lastHunk.getBuffer());
|
RawText lhrt = new RawText(lastHunk.getBuffer());
|
||||||
return lhrt.getString(lhrt.size() - 1).equals(
|
return lhrt.getString(lhrt.size() - 1)
|
||||||
"\\ No newline at end of file"); //$NON-NLS-1$
|
.equals("\\ No newline at end of file"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue