diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-01-19 11:20:27 -0500 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2013-01-19 11:20:27 -0500 |
commit | ab439eed6eab4fbd09d185e4e269da2c5589b42e (patch) | |
tree | 05469b50dad961ee64a56ef13eb5b3cbfbf7fcbe /org.eclipse.jgit | |
parent | 38b503601a6d3552a558751871906354ba1beca5 (diff) | |
parent | 3d18f65af1341bc1ebc8c5c1e92726d701e5a55e (diff) | |
download | jgit-ab439eed6eab4fbd09d185e4e269da2c5589b42e.tar.gz jgit-ab439eed6eab4fbd09d185e4e269da2c5589b42e.zip |
Merge "Fix patch application WRT windows line endings."
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java index 2147a2e5c4..6a945e4d39 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/ApplyCommand.java @@ -238,13 +238,10 @@ public class ApplyCommand extends GitCommand<ApplyResult> { if (!isChanged(oldLines, newLines)) return; // don't touch the file StringBuilder sb = new StringBuilder(); - final String eol = rt.size() == 0 - || (rt.size() == 1 && rt.isMissingNewlineAtEnd()) ? "\n" : rt //$NON-NLS-1$ - .getLineDelimiter(); for (String l : newLines) { - sb.append(l); - if (eol != null) - sb.append(eol); + // don't bother handling line endings - if it was windows, the \r is + // still there! + sb.append(l).append('\n'); } sb.deleteCharAt(sb.length() - 1); FileWriter fw = new FileWriter(f); @@ -252,7 +249,7 @@ public class ApplyCommand extends GitCommand<ApplyResult> { fw.close(); } - private boolean isChanged(List<String> ol, List<String> nl) { + private static boolean isChanged(List<String> ol, List<String> nl) { if (ol.size() != nl.size()) return true; for (int i = 0; i < ol.size(); i++) |