Reject pushing to invalid reference names

If a reference name is not valid according to Git's rules for
the allowable syntax, or it contains "//" because a typo on the
client side introduced an unnecessary slash, reject the command
with an error.

Bug: issue 466
Change-Id: I89d8137a89225bc31813f5870d75568e5080b059
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-03-04 20:01:11 -08:00
parent 6f2ccde49b
commit 7e30c72d03

View File

@@ -404,6 +404,12 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
continue;
}
if (!Repository.isValidRefName(cmd.getRefName())
|| cmd.getRefName().contains("//")) {
reject(cmd, "not valid ref");
continue;
}
if (cmd.getRefName().startsWith(NEW_CHANGE)) {
parseNewChangeCommand(cmd);
continue;