Use empty NoteMap to simplify reject commit check

JGit now has this empty NoteMap constructor, which makes it easy
to ensure the reject commit map is never null.  Searching an empty
note map with contains() is about as fast as the null pointer check
was before, so this is a fairly painless change.

Change-Id: I15da27211ed678c48993620d458f2bb0bd4f1d5f
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-12-10 16:43:44 -08:00
parent 2edc2b3d06
commit 0979e9059c

View File

@@ -734,7 +734,7 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
try {
Ref ref = repo.getRef(rejectNotes);
if (ref == null) {
return null;
return NoteMap.newEmptyMap();
}
RevWalk rw = rp.getRevWalk();
@@ -1520,7 +1520,7 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
}
// Check for banned commits to prevent them from entering the tree again.
if (rejectCommits != null && rejectCommits.contains(c)) {
if (rejectCommits.contains(c)) {
reject(newChange, "contains banned commit " + c.getName());
return false;
}