Browse Source

Merge changes Icf0970dd,Ice5ec10a into stable-3.4

* changes:
  Fix two nits about DirCacheEntry constructors
  Detect buffering failures while writing rebase todo file
tags/v3.4.2.201412180340-r
Christian Halstrick 9 years ago
parent
commit
c1b9b50b5e

+ 4
- 4
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java View File



if (mightBeRacilyClean(smudge_s, smudge_ns)) if (mightBeRacilyClean(smudge_s, smudge_ns))
smudgeRacilyClean(); smudgeRacilyClean();

} }


/** /**
* or DirCache file. * or DirCache file.
*/ */
public DirCacheEntry(final String newPath) { public DirCacheEntry(final String newPath) {
this(Constants.encode(newPath));
this(Constants.encode(newPath), STAGE_0);
} }


/** /**
if (!isValidPath(newPath)) if (!isValidPath(newPath))
throw new InvalidPathException(toString(newPath)); throw new InvalidPathException(toString(newPath));
if (stage < 0 || 3 < stage) 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]; info = new byte[INFO_LEN];
infoOffset = 0; infoOffset = 0;

+ 6
- 7
org.eclipse.jgit/src/org/eclipse/jgit/lib/RebaseTodoFile.java View File



package org.eclipse.jgit.lib; package org.eclipse.jgit.lib;


import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.OutputStream;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;


import org.eclipse.jgit.lib.RebaseTodoLine.Action; import org.eclipse.jgit.lib.RebaseTodoLine.Action;
import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.RawParseUtils; 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 * Offers methods to read and write files formatted like the git-rebase-todo
*/ */
public void writeRebaseTodoFile(String path, List<RebaseTodoLine> steps, public void writeRebaseTodoFile(String path, List<RebaseTodoLine> steps,
boolean append) throws IOException { 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 { try {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (RebaseTodoLine step : steps) { for (RebaseTodoLine step : steps) {
sb.append(" "); //$NON-NLS-1$ sb.append(" "); //$NON-NLS-1$
sb.append(step.getShortMessage().trim()); sb.append(step.getShortMessage().trim());
} }
fw.write(sb.toString());
fw.newLine();
sb.append('\n');
fw.write(Constants.encode(sb.toString()));
} }
} finally { } finally {
fw.close(); fw.close();

Loading…
Cancel
Save