Add HunkHeader to represent a single hunk of a file within a patch
commitad5c6c4cfa166d7203f0c6373bef46982f402ec6
authorShawn O. Pearce <spearce@spearce.org>
Thu, 11 Dec 2008 04:58:42 +0000 (10 20:58 -0800)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Sat, 13 Dec 2008 02:13:25 +0000 (13 03:13 +0100)
tree2c2b984ffaa7e6f38216cd80c58aa04aac77ee7b
parent7ffd095d7874733d0cb73edd9f1eeff915790115
Add HunkHeader to represent a single hunk of a file within a patch

The hunk header parses the lines of the hunk, counting up the body
to ensure it matches with the header line.  We store the hunks on
on the FileHeader, providing public access to them after a patch
has been parsed.

If the line counts in the body differ from the header we don't make
that an immediate error.  This permits a future implementation of
something like "git apply --recount", where the hunk headers can be
recomputed based on the actual hunk contents after a human has done
manual editing.  We may also need to parse a corrupt patch and show
it in a visual tool for a human to repair, so aborting with any sort
of exception isn't useful.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit.test/tst/org/spearce/jgit/patch/FileHeaderTest.java
org.spearce.jgit.test/tst/org/spearce/jgit/patch/PatchTest.java
org.spearce.jgit/src/org/spearce/jgit/patch/FileHeader.java
org.spearce.jgit/src/org/spearce/jgit/patch/HunkHeader.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java