diff options
author | Mathias Kinzler <mathias.kinzler@sap.com> | 2010-11-26 08:29:48 +0100 |
---|---|---|
committer | Mathias Kinzler <mathias.kinzler@sap.com> | 2010-11-26 12:22:40 +0100 |
commit | 12b635043506211fe9c873f14fc8e03546d6081d (patch) | |
tree | 328d2fcff8ff7edb8baf2b81478841c8be87226f /org.eclipse.jgit | |
parent | 3da6dbaf81bffebf3d95b373d8aeb9002d0f2130 (diff) | |
download | jgit-12b635043506211fe9c873f14fc8e03546d6081d.tar.gz jgit-12b635043506211fe9c873f14fc8e03546d6081d.zip |
RebaseCommand: trim line endings when reading files
In order to enable interoperability with the command line, we need to
remove line feeds when reading the files.
Change-Id: Ie2f5799037a60243bb4fac52346908ff85c0ce5d
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java | 9 |
1 files changed, 7 insertions, 2 deletions
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 0938ec1051..f924590417 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<RebaseResult> { 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<RebaseResult> { } 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 { |