diff options
author | Robin Stocker <robin@nibor.org> | 2013-05-10 18:16:36 +0200 |
---|---|---|
committer | Robin Stocker <robin@nibor.org> | 2013-05-15 12:23:40 +0200 |
commit | 92189b2df42e3eb9ba651b7f9d989ab556f49396 (patch) | |
tree | a13cb5184b804ee0f2ce1fedf479158f494100bf /org.eclipse.jgit | |
parent | c93a59330249677cd990820b59558a39f747009f (diff) | |
download | jgit-92189b2df42e3eb9ba651b7f9d989ab556f49396.tar.gz jgit-92189b2df42e3eb9ba651b7f9d989ab556f49396.zip |
Fix DiffFormatter NPEs for DiffEntry without content change
DiffEntry.getOldId() returns null for a diff without an index line (e.g.
only mode changed, rename without content change).
Bug: 407743
Change-Id: I42eac87421f2a53c985af260a253338f578492bc
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java | 7 |
1 files changed, 6 insertions, 1 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 11848e2c99..f660d6bbd9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java @@ -912,6 +912,11 @@ public class DiffFormatter { editList = new EditList(); type = PatchType.UNIFIED; + } else if (ent.getOldId() == null || ent.getNewId() == null) { + // Content not changed (e.g. only mode, pure rename) + editList = new EditList(); + type = PatchType.UNIFIED; + } else { assertHaveRepository(); @@ -1106,7 +1111,7 @@ public class DiffFormatter { o.write('\n'); } - if (!ent.getOldId().equals(ent.getNewId())) { + if (ent.getOldId() != null && !ent.getOldId().equals(ent.getNewId())) { formatIndexLine(o, ent); } } |