Files view crashes browser in a repository with 100K branches

ZenDesk issue: https://gitlab.zendesk.com/agent/tickets/22337

Test repo: https://gitlab.com/baparici/many-branches

I was running more tests with this. 
After pushing a repo with 100k branches, as I said, the application 
return 502 however, from the bare repository in the file system, we've 
seen that we have

/ls -lrt refs/heads/// 
//total 45001// 
//-rw-r--r--. 1 git git 41 may 31 16:28 branch_000000000001// 
//-rw-r--r--. 1 git git 41 may 31 16:28 branch_0000000000010// 
//-rw-r--r--. 1 git git 41 may 31 16:28 branch_00000000000100// 
//-rw-r--r--. 1 git git 41 may 31 16:28 branch_000000000001000// 
//-rw-r--r--. 1 git git 41 may 31 16:28 branch_0000000000010000// 
//-rw-r--r--. 1 git git 41 may 31 16:28 branch_00000000000100000// 
//-rw-r--r--. 1 git git 41 may 31 16:28 branch_0000000000010001// 
//-rw-r--r--. 1 git git 41 may 31 16:28 branch_0000000000010002// 
/

... one file per branch.

By running /git pack-refs --all/ it becomes 
/-bash-4.2$ ls -lrt refs/heads/// 
//total 0// 
//-bash-4.2$ ls -lrt packed-refs // 
//-rw-r--r--. 1 git git 7667955 Jun 3 15:46 packed-refs/

... only one packed-refs file with the list of all branches instead of 
one file per branch, which is far more expensive to process.

Now, visiting the web site for that project, works correctly. Even 
clicking in "Branches", you see all them enumerated.

But, clicking in "Files", the browser is not able to handle it and 
crashes. My feeling is the drop-down menu with the branch names is being 
fed by GitLab with the 100k names in one go.

/cc: @jschatz1