aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/diff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-07-03 16:59:06 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-07-03 16:59:06 -0700
commitbd8740dc1440e5b2aca1464404182105b2dc1853 (patch)
tree635e40bff668e6d8ed0d5c28a2cc100a5149f0e0 /org.eclipse.jgit/src/org/eclipse/jgit/diff
parent5be90be996551302d59a07ea49af5e5b9fed1cb3 (diff)
downloadjgit-bd8740dc1440e5b2aca1464404182105b2dc1853.tar.gz
jgit-bd8740dc1440e5b2aca1464404182105b2dc1853.zip
Format submodule links during differences
Instead of crashing, output a submodule link with the simple "Subproject commit $fullid\n" syntax used by C Git. Change-Id: Iae8646941683fb19b73fb038217d2e3bf5f77fa9 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/diff')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
index 00cfe8b087..e114b92209 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
@@ -46,6 +46,7 @@ package org.eclipse.jgit.diff;
import static org.eclipse.jgit.lib.Constants.encode;
import static org.eclipse.jgit.lib.Constants.encodeASCII;
+import static org.eclipse.jgit.lib.FileMode.GITLINK;
import java.io.IOException;
import java.io.OutputStream;
@@ -232,16 +233,27 @@ public class DiffFormatter {
out.write(encode("--- " + oldName + '\n'));
out.write(encode("+++ " + newName + '\n'));
- byte[] aRaw = open(ent.getOldMode(), ent.getOldId());
- byte[] bRaw = open(ent.getNewMode(), ent.getNewId());
+ if (ent.getOldMode() == GITLINK || ent.getNewMode() == GITLINK) {
+ if (ent.getOldMode() == GITLINK) {
+ out.write(encodeASCII("-Subproject commit "
+ + ent.getOldId().name() + "\n"));
+ }
+ if (ent.getNewMode() == GITLINK) {
+ out.write(encodeASCII("+Subproject commit "
+ + ent.getNewId().name() + "\n"));
+ }
+ } else {
+ byte[] aRaw = open(ent.getOldMode(), ent.getOldId());
+ byte[] bRaw = open(ent.getNewMode(), ent.getNewId());
- if (RawText.isBinary(aRaw) || RawText.isBinary(bRaw)) {
- out.write(encodeASCII("Binary files differ\n"));
+ if (RawText.isBinary(aRaw) || RawText.isBinary(bRaw)) {
+ out.write(encodeASCII("Binary files differ\n"));
- } else {
- RawText a = newRawText(aRaw);
- RawText b = newRawText(bRaw);
- formatEdits(a, b, new MyersDiff(a, b).getEdits());
+ } else {
+ RawText a = newRawText(aRaw);
+ RawText b = newRawText(bRaw);
+ formatEdits(a, b, new MyersDiff(a, b).getEdits());
+ }
}
}