diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java index 0938ec105..f92459041 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java @@ -396,6 +396,7 @@ public class RebaseCommand extends GitCommand { FileOutputStream fos = new FileOutputStream(file); try { fos.write(content.getBytes("UTF-8")); + fos.write('\n'); } finally { fos.close(); } @@ -458,8 +459,12 @@ public class RebaseCommand extends GitCommand { } private String readFile(File directory, String fileName) throws IOException { - return RawParseUtils - .decode(IO.readFully(new File(directory, fileName))); + byte[] content = IO.readFully(new File(directory, fileName)); + // strip off the last LF + int end = content.length; + while (0 < end && content[end - 1] == '\n') + end--; + return RawParseUtils.decode(content, 0, end); } private void checkoutCommit(RevCommit commit) throws IOException {