summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMathias Kinzler2010-11-26 02:29:48 (EST)
committer Mathias Kinzler2010-11-26 06:22:40 (EST)
commit12b635043506211fe9c873f14fc8e03546d6081d (patch)
tree328d2fcff8ff7edb8baf2b81478841c8be87226f
parent3da6dbaf81bffebf3d95b373d8aeb9002d0f2130 (diff)
downloadjgit-12b635043506211fe9c873f14fc8e03546d6081d.zip
jgit-12b635043506211fe9c873f14fc8e03546d6081d.tar.gz
jgit-12b635043506211fe9c873f14fc8e03546d6081d.tar.bz2
RebaseCommand: trim line endings when reading filesrefs/changes/40/1940/4
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>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java9
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 0938ec1..f924590 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 {