Really don't allow commits to replace in wrong project

In afca17b92a35e5e7ee4f62208fd9440226b26ee9 I tried to add this block
to validate that a replacement commit isn't mapped into the wrong
project by accident.  Unfortunately that test wasn't performed in the
right section of code.  We really need it earlier, as we parse through
the mapping supplied by the client.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce 2009-08-20 08:14:16 -07:00
parent 3ca1dcf387
commit ebb4e64cfc

View File

@ -548,6 +548,10 @@ final class Receive extends AbstractGitCommand {
reject(cmd, "change " + changeId.get() + " not found");
return;
}
if (!proj.getNameKey().equals(changeEnt.getDest().getParentKey())) {
reject(cmd, "change " + changeId.get() + " not in " + proj.getName());
return;
}
if (changeEnt.getStatus().isClosed()) {
reject(cmd, "change " + changeId.get() + " closed");
return;
@ -800,12 +804,6 @@ final class Receive extends AbstractGitCommand {
reject(cmd, "change " + changeId.get() + " closed");
return null;
}
if (change.getDest() == null
|| !proj.getNameKey().equals(change.getDest().getParentKey())) {
reject(cmd, "change " + changeId.get() + " not in "
+ proj.getName());
return null;
}
} else {
change = changeCache.get(changeId);
}