[JGIT PATCH 07/12] Allow a stray LF at the end of a hunk
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- Dec 12, 2008, 22:05 UTC
- Message-ID
- <1229119558-1293-8-git-send-email-spearce@spearce.org>
- In-Reply-To
- <1229119558-1293-7-git-send-email-spearce@spearce.org>
If a hunk ends and is followed by a stray LF its not worth creating a warning for. A single extra blank line isn't all that interesting relative to the other sorts of data we might find at the end of a patch hunk.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org> --- .../src/org/spearce/jgit/patch/Patch.java | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java b/org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java index 05d034d..51f1fe5 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java +++ b/org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java @@ -287,9 +287,16 @@ private int parseHunks(final FileHeader fh, int c, final int end) { c = h.parseBody(this, end); h.endOffset = c; fh.addHunk(h); - if (c < end && buf[c] != '@' && buf[c] != 'd' - && match(buf, c, SIG_FOOTER) < 0) { - warn(buf, c, "Unexpected hunk trailer"); + if (c < end) { + switch (buf[c]) { + case '@': + case 'd': + case '\n': + break; + default: + if (match(buf, c, SIG_FOOTER) < 0) + warn(buf, c, "Unexpected hunk trailer"); + } } continue; }
-- 1.6.1.rc2.306.ge5d5e