ReceiveCommits: Fix NPE when pushing to refs/changes/n

Change-Id: Iccf24e5262dcfe8e0fde0b63e1ef5411d7266592
This commit is contained in:
David Pursehouse 2015-02-24 11:21:27 +09:00
parent ebab92aabd
commit 7ee9dc17b4
2 changed files with 13 additions and 1 deletions

View File

@ -201,6 +201,18 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
assertThat(cr.all.get(0).value.intValue()).is(2);
}
@Test
public void testPushNewPatchsetToRefsChanges() throws GitAPIException,
IOException, OrmException {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
"b.txt", "anotherContent", r.getChangeId());
r = push.to(git, "refs/changes/" + r.getChange().change().getId().get());
r.assertOkStatus();
}
@Test
public void testPushForMasterWithApprovals_MissingLabel() throws GitAPIException,
IOException {

View File

@ -2041,7 +2041,7 @@ public class ReceiveCommits {
@Override
public PatchSet.Id call() throws OrmException, IOException, NoSuchChangeException {
try {
if (magicBranch.edit) {
if (magicBranch != null && magicBranch.edit) {
return upsertEdit();
} else if (caller == Thread.currentThread()) {
return insertPatchSet(db);