Browse Source

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>
stable-0.9
Shawn O. Pearce 15 years ago
parent
commit
bd8740dc14
  1. 12
      org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java

12
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.encode;
import static org.eclipse.jgit.lib.Constants.encodeASCII; import static org.eclipse.jgit.lib.Constants.encodeASCII;
import static org.eclipse.jgit.lib.FileMode.GITLINK;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -232,6 +233,16 @@ public class DiffFormatter {
out.write(encode("--- " + oldName + '\n')); out.write(encode("--- " + oldName + '\n'));
out.write(encode("+++ " + newName + '\n')); out.write(encode("+++ " + newName + '\n'));
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[] aRaw = open(ent.getOldMode(), ent.getOldId());
byte[] bRaw = open(ent.getNewMode(), ent.getNewId()); byte[] bRaw = open(ent.getNewMode(), ent.getNewId());
@ -244,6 +255,7 @@ public class DiffFormatter {
formatEdits(a, b, new MyersDiff(a, b).getEdits()); formatEdits(a, b, new MyersDiff(a, b).getEdits());
} }
} }
}
/** /**
* Construct a RawText sequence for use with {@link MyersDiff}. * Construct a RawText sequence for use with {@link MyersDiff}.

Loading…
Cancel
Save