diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2014-11-26 07:54:07 -0500 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2014-11-26 07:54:07 -0500 |
commit | c1b9b50b5ec0fca54d5d05f53da19f9af7178c86 (patch) | |
tree | 17c80e277cf60880eb745bf8a73b5e9a7f1d9db7 | |
parent | f9088d6dda16c9b9fd2898dd12a6f704db963dcf (diff) | |
parent | 98c75a7ca2218208dc7951ec2bf3cf352fb3d6df (diff) | |
download | jgit-c1b9b50b5ec0fca54d5d05f53da19f9af7178c86.tar.gz jgit-c1b9b50b5ec0fca54d5d05f53da19f9af7178c86.zip |
Merge changes Icf0970dd,Ice5ec10a into stable-3.4
* changes:
Fix two nits about DirCacheEntry constructors
Detect buffering failures while writing rebase todo file
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java | 8 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java | 13 |
2 files changed, 10 insertions, 11 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java index 65188c8f43..458cd98e4b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java @@ -203,7 +203,6 @@ public class DirCacheEntry { if (mightBeRacilyClean(smudge_s, smudge_ns)) smudgeRacilyClean(); - } /** @@ -217,7 +216,7 @@ public class DirCacheEntry { * or DirCache file. */ public DirCacheEntry(final String newPath) { - this(Constants.encode(newPath)); + this(Constants.encode(newPath), STAGE_0); } /** @@ -269,8 +268,9 @@ public class DirCacheEntry { if (!isValidPath(newPath)) throw new InvalidPathException(toString(newPath)); if (stage < 0 || 3 < stage) - throw new IllegalArgumentException(MessageFormat.format(JGitText.get().invalidStageForPath - , stage, toString(newPath))); + throw new IllegalArgumentException(MessageFormat.format( + JGitText.get().invalidStageForPath, + stage, toString(newPath))); info = new byte[INFO_LEN]; infoOffset = 0; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java index ef61e22032..4ebe5fedf3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java @@ -43,17 +43,17 @@ package org.eclipse.jgit.lib; -import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStreamWriter; +import java.io.OutputStream; import java.util.LinkedList; import java.util.List; import org.eclipse.jgit.lib.RebaseTodoLine.Action; import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.RawParseUtils; +import org.eclipse.jgit.util.io.SafeBufferedOutputStream; /** * Offers methods to read and write files formatted like the git-rebase-todo @@ -216,9 +216,8 @@ public class RebaseTodoFile { */ public void writeRebaseTodoFile(String path, List<RebaseTodoLine> steps, boolean append) throws IOException { - BufferedWriter fw = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(new File(repo.getDirectory(), path), - append), Constants.CHARACTER_ENCODING)); + OutputStream fw = new SafeBufferedOutputStream(new FileOutputStream( + new File(repo.getDirectory(), path), append)); try { StringBuilder sb = new StringBuilder(); for (RebaseTodoLine step : steps) { @@ -232,8 +231,8 @@ public class RebaseTodoFile { sb.append(" "); //$NON-NLS-1$ sb.append(step.getShortMessage().trim()); } - fw.write(sb.toString()); - fw.newLine(); + sb.append('\n'); + fw.write(Constants.encode(sb.toString())); } } finally { fw.close(); |