Setting protected branches in empty repository fails silently

Summary

When you click on settings -> protected branches in an empty repository, the action fails silently.

Seems related to #97 (closed) perhaps...

Steps to reproduce

Create new/empty repository Click on settings (wheel) button -> protected branches

Expected behavior

It's a minor thing, but not very user-friendly. Button should either be grayed out on an empty repository or an error should pop up.

Actual behavior

Page reloads with no feedback

Relevant logs and/or screenshots

Server logs also don't show any useful information

Output of checks

Results of GitLab application Check

Checking GitLab Shell ...

GitLab Shell version >= 3.4.0 ? ... OK (3.4.0)
Repo base directory exists?
default... yes
Repo storage directories are symlinks?
default... no
Repo paths owned by git:git?
default... yes
Repo paths access is drwxrws---?
default... yes
hooks directories in repos are links: ... 
6/1 ... ok
2/2 ... repository is empty
7/3 ... repository is empty
8/4 ... ok
9/5 ... ok
10/6 ... ok
15/7 ... ok
21/8 ... repository is empty
20/9 ... ok
18/10 ... ok
19/11 ... ok
16/12 ... ok
17/13 ... ok
27/14 ... ok
35/20 ... ok
37/21 ... ok
38/22 ... ok
28/23 ... ok
39/24 ... ok
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK
Send ping to redis server: OK
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Sidekiq ...

Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Reply by email ...

Reply by email is disabled in config/gitlab.yml

Checking Reply by email ... Finished

LDAP users with access to your GitLab server (only showing the first 100 results)
Server: [scrubbed]
  DN: CN=[scrubbed, ~100 rows]

Checking LDAP ... Finished

Checking GitLab ...

Git configured with autocrlf=input? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory setup correctly? ... yes
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
projects have namespace: ... 
6/1 ... yes
2/2 ... yes
7/3 ... yes
8/4 ... yes
9/5 ... yes
10/6 ... yes
15/7 ... yes
21/8 ... yes
20/9 ... yes
18/10 ... yes
19/11 ... yes
16/12 ... yes
17/13 ... yes
27/14 ... yes
35/20 ... yes
37/21 ... yes
38/22 ... yes
28/23 ... yes
39/24 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.1.0 ? ... yes (2.3.1)
Your git bin path is "/opt/gitlab/embedded/bin/git"
Git version >= 2.7.3 ? ... yes (2.7.4)
Active users: 9

Checking GitLab ... Finished

Results of GitLab environment info

System information
System:   Ubuntu 14.04
Current User: git
Using RVM:  no
Ruby Version: 2.3.1p112
Gem Version:  2.6.6
Bundler Version:2.3.0
Rake Version: 10.5.0
Sidekiq Version:4.1.4

GitLab information
Version:  8.11.2-ee
Revision: e21c93f
Directory:  /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 9.2.18
URL:    https://gitlab.[scrubbed].com
HTTP Clone URL: https://gitlab.[scrubbed].com/some-group/some-project.git
SSH Clone URL:  git@gitlab.[scrubbed].com:some-group/some-project.git
Elasticsearch:  no
Geo:    no
Using LDAP: yes
Using Omniauth: no

GitLab Shell
Version:  3.4.0
Repository storage paths:
- default:  /var/opt/gitlab/git-data/repositories
Hooks:    /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git:    /opt/gitlab/embedded/bin/git 
Assignee Loading
Time tracking Loading