Validate branch-names and references in WebUI, API

#### What does this MR do?

This PR adds validation for invalid input for branch and tag names. Validating a name is done using the git subcommand `git check-ref-format`. If an error occurs, an error message is shown indicating a wrong input.

This behavior is also added to the API. If an error occurs a 405 error responded.
  
#### Why was this MR needed?

Currently when entering an invalid name for branch or invalid reference name GitLab fails silently or raises a 500 error. This behavior also applies if the branch already exists. 

#### What are the relevant issue numbers / Feature requests?

This PR fixes:

* #7381
* #6805
* https://gitlab.com/gitlab-org/gitlab-ce/issues/238
* https://gitlab.com/gitlab-org/gitlab-ce/issues/436
* http://feedback.gitlab.com/forums/176466-general/suggestions/6171376-fix-error-500-when-create-branch
* http://feedback.gitlab.com/forums/176466-general/suggestions/6201425-validate-branch-name-uniqueness-on-web-ui-creation

#### TODO
 - [ ] Add support for tag validation

Many thanks to @jvanbaarsen for his help for a ruby beginner.

@randx Creating a new branch within the spinach test doesn't work. The current testcases passes because the branch already exists in the test repository. @jvanbaarsen also looked at this problem, but doesn't know what's going on here. 

/cc @cirosantilli 
There seems to be a line ending issue :worried: