Don't abbreviate here.  Create the full ObjectId.

Really what you should do is:

  MutableObjectId idBuf = new MutableObjectId();
  while (walk.next()) {
    DiffEntry entry = new DiffEntry();

    tw.getObjectId(idBuf, 0);
    entry.oldId = AbbreviatedObjectId.fromObjectId(idBuf);

    tw.getObjectId(idBuf, 1);
    entry.newId = AbbreviatedObjectId.fromObjectId(idBuf);
  }

That keeps object allocation down to a minimum by using a locally allocated, but mutable, object id buffer.