Browse Source

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>
stable-0.10
Mathias Kinzler 14 years ago
parent
commit
12b6350435
  1. 9
      org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java

9
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 {

Loading…
Cancel
Save