diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2013-02-02 15:06:22 -0500 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2013-02-02 15:06:22 -0500 |
commit | aae08070c6a5456ec2ef4a2700d201bd76a3163c (patch) | |
tree | 485c86a7d162bd60697e8cefa0f77443a7027c6f | |
parent | 2c40482d0f8da91ed9d5468a04a02c0c636b674c (diff) | |
parent | 0d09b1cab7bcadd43be6c023028f7aca579944ab (diff) | |
download | jgit-aae08070c6a5456ec2ef4a2700d201bd76a3163c.tar.gz jgit-aae08070c6a5456ec2ef4a2700d201bd76a3163c.zip |
Merge "Extract method to output the first header line of a git diff"
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java index 4af1084bf4..fe0db33d3a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java @@ -299,7 +299,7 @@ public class DiffFormatter { /** * Get the prefix applied in front of new file paths. - * + * * @return the prefix * @since 2.0 */ @@ -1008,6 +1008,31 @@ public class DiffFormatter { 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(); @@ -1016,11 +1041,7 @@ public class DiffFormatter { 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: |