org.eclipse.jgit.diff
Class DiffFormatter

java.lang.Object
  extended by org.eclipse.jgit.diff.DiffFormatter

public class DiffFormatter
extends java.lang.Object

Format an EditList as a Git style unified patch script.


Constructor Summary
DiffFormatter()
          Create a new formatter with a default level of context.
 
Method Summary
 void format(java.io.OutputStream out, FileHeader head, RawText a, RawText b)
          Format a patch script, reusing a previously parsed FileHeader.
 void setContext(int lineCount)
          Change the number of lines of context to display.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiffFormatter

public DiffFormatter()
Create a new formatter with a default level of context.

Method Detail

setContext

public void setContext(int lineCount)
Change the number of lines of context to display.

Parameters:
lineCount - number of lines of context to see before the first modification and after the last modification within a hunk of the modified file.

format

public void format(java.io.OutputStream out,
                   FileHeader head,
                   RawText a,
                   RawText b)
            throws java.io.IOException
Format a patch script, reusing a previously parsed FileHeader.

This formatter is primarily useful for editing an existing patch script to increase or reduce the number of lines of context within the script. All header lines are reused as-is from the supplied FileHeader.

Parameters:
out - stream to write the patch script out to.
head - existing file header containing the header lines to copy.
a - text source for the pre-image version of the content. This must match the content of FileHeader.getOldId().
b - text source for the post-image version of the content. This must match the content of FileHeader.getNewId().
Throws:
java.io.IOException - writing to the supplied stream failed.