Ensure the commit body is parsed before getting the committer

If we have done any sort of revision traversals earlier the RevWalk
may have discarded the body of the commit, even if we really
wanted it.  This can lead to an NPE inside of the getCommitterIdent
or getAuthorIdent methods, so its a good idea to ensure the body has
been parsed first.  This turns into a quick no-op if it has already
been parsed, so its relatively simple to always check first.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce 2009-08-20 09:59:43 -07:00
parent 5169e14558
commit 1cc1fb23db

View File

@ -59,6 +59,7 @@ import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spearce.jgit.errors.MissingObjectException;
import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.ObjectId;
import org.spearce.jgit.lib.PersonIdent;
@ -1090,7 +1091,9 @@ final class Receive extends AbstractGitCommand {
String mergedIntoRef;
}
private boolean validCommitter(final ReceiveCommand cmd, final RevCommit c) {
private boolean validCommitter(final ReceiveCommand cmd, final RevCommit c)
throws MissingObjectException, IOException {
rp.getRevWalk().parseBody(c);
final PersonIdent committer = c.getCommitterIdent();
final PersonIdent author = c.getAuthorIdent();