/**
* Get the prefix applied in front of new file paths.
- *
+ *
* @return the prefix
* @since 2.0
*/
return false;
}
+ /**
+ * Output the first header line
+ *
+ * @param o
+ * The stream the formatter will write the first header line to
+ * @param type
+ * The {@link ChangeType}
+ * @param oldPath
+ * old path to the file
+ * @param newPath
+ * new path to the file
+ * @throws IOException
+ * the stream threw an exception while writing to it.
+ */
+ protected void formatGitDiffFirstHeaderLine(ByteArrayOutputStream o,
+ final ChangeType type, final String oldPath, final String newPath)
+ throws IOException {
+ o.write(encodeASCII("diff --git ")); //$NON-NLS-1$
+ o.write(encode(quotePath(oldPrefix + (type == ADD ? newPath : oldPath))));
+ o.write(' ');
+ o.write(encode(quotePath(newPrefix
+ + (type == DELETE ? oldPath : newPath))));
+ o.write('\n');
+ }
+
private void formatHeader(ByteArrayOutputStream o, DiffEntry ent)
throws IOException {
final ChangeType type = ent.getChangeType();
final FileMode oldMode = ent.getOldMode();
final FileMode newMode = ent.getNewMode();
- o.write(encodeASCII("diff --git ")); //$NON-NLS-1$
- o.write(encode(quotePath(oldPrefix + (type == ADD ? newp : oldp))));
- o.write(' ');
- o.write(encode(quotePath(newPrefix + (type == DELETE ? oldp : newp))));
- o.write('\n');
+ formatGitDiffFirstHeaderLine(o, type, oldp, newp);
switch (type) {
case ADD: