Style-nit:  We avoid double method calls like this.  Instead:

  RevCommit c;
  while ((c = walk.next()) != null)
    ret.add(c);

or even:

  for (;;) {
    RevCommit c = walk.next();
    if (c != null)
      ret.add(c);
    else
      break;
  }