Allow FileHeader to create its HunkHeader children
commitcf34c3fcc676f6603f2dfdbcb149b859bf55044c
authorShawn O. Pearce <spearce@spearce.org>
Fri, 12 Dec 2008 22:05:50 +0000 (12 14:05 -0800)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Sat, 13 Dec 2008 02:13:27 +0000 (13 03:13 +0100)
treea732308ba41b5c52e5240a8720cb0d45fb3bc4e7
parent3ccf470335d86b30702a52c7382de42c0b35d83d
Allow FileHeader to create its HunkHeader children

By using a factory method on FileHeader we can later subclass the
FileHeader class to handle "diff --cc" style patches, and let it
create its own subclass of HunkHeader to handle the specialized
form of the n-way diff.

The getParentCount() method is hard-coded to return 1 in the 2-way
diff case as there is exactly one parent.  But in a "diff --cc" we
need to verify the hunk header has the same number of parents as
the file header in order to parse the hunk.  So a subclass of the
FileHeader would need to override getParentCount() to return the
actual number of '@' symbols (less 1) that should appear in each
hunk header line.  (E.g. a 3-way diff shows "@@@ -" so the parent
count should be 2.)

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit/src/org/spearce/jgit/patch/FileHeader.java
org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java