According to the git diff manual page these two formats share the same file structure, so we can parse them with the same function. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- .../src/org/spearce/jgit/patch/Patch.java | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 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 e1e79b7..77ae02f 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java +++ b/org.spearce.jgit/src/org/spearce/jgit/patch/Patch.java @@ -57,6 +57,8 @@ private static final byte[] DIFF_CC = encodeASCII("diff --cc "); + private static final byte[] DIFF_COMBINED = encodeASCII("diff --combined "); + private static final byte[][] BIN_HEADERS = new byte[][] { encodeASCII("Binary files "), encodeASCII("Files "), }; @@ -177,7 +179,9 @@ private int parseFile(final byte[] buf, int c, final int end) { if (match(buf, c, DIFF_GIT) >= 0) return parseDiffGit(buf, c, end); if (match(buf, c, DIFF_CC) >= 0) - return parseDiffCC(buf, c, end); + return parseDiffCombined(DIFF_CC, buf, c, end); + if (match(buf, c, DIFF_COMBINED) >= 0) + return parseDiffCombined(DIFF_COMBINED, buf, c, end); // Junk between files? Leading junk? Traditional // (non-git generated) patch? @@ -227,9 +231,10 @@ private int parseDiffGit(final byte[] buf, final int start, final int end) { return ptr; } - private int parseDiffCC(final byte[] buf, final int start, final int end) { - final FileHeader fh = new FileHeader(buf, start); - int ptr = fh.parseGitFileName(start + DIFF_CC.length, end); + private int parseDiffCombined(final byte[] hdr, final byte[] buf, + final int start, final int end) { + final CombinedFileHeader fh = new CombinedFileHeader(buf, start); + int ptr = fh.parseGitFileName(start + hdr.length, end); if (ptr < 0) return skipFile(buf, start, end); @@ -269,6 +274,8 @@ private int parseHunks(final FileHeader fh, int c, final int end) { break; if (match(buf, c, DIFF_CC) >= 0) break; + if (match(buf, c, DIFF_COMBINED) >= 0) + break; if (match(buf, c, OLD_NAME) >= 0) break; if (match(buf, c, NEW_NAME) >= 0) -- 1.6.1.rc2.306.ge5d5e -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html