Fix Error 500 occuring with repositories that have a bad HEAD
Fix Error 500 occuring with repositories that have a bad HEAD

A repository could have objects but no valid HEAD, causing
`project.commit` to be `nil`.

mr-dxdy/gitlabhq,louahola/gitlabhq,duduribeiro/gitlabhq,martijnvermaat/gitlabhq,mrb/gitlabhq,NKMR6194/gitlabhq,dplarson/gitlabhq,LUMC/gitlabhq,openwide-java/gitlabhq,fscherwi/gitlabhq,cui-liqiang/gitlab-ce,htve/GitlabForChinese,NKMR6194/gitlabhq,yatish27/gitlabhq,mrb/gitlabhq,screenpages/gitlabhq,ferdinandrosario/gitlabhq,MauriceMohlek/gitlabhq,mmkassem/gitlabhq,mr-dxdy/gitlabhq,screenpages/gitlabhq,dwrensha/gitlabhq,shinexiao/gitlabhq,salipro4ever/gitlabhq,koreamic/gitlabhq,fscherwi/gitlabhq,MauriceMohlek/gitlabhq,sonalkr132/gitlabhq,jrjang/gitlab-ce,fpgentil/gitlabhq,jirutka/gitlabhq,MauriceMohlek/gitlabhq,sue445/gitlabhq,axilleas/gitlabhq,SVArago/gitlabhq,yatish27/gitlabhq,daiyu/gitlab-zh,joalmeid/gitlabhq,axilleas/gitlabhq,sue445/gitlabhq,jrjang/gitlabhq,dplarson/gitlabhq,gopeter/gitlabhq,NKMR6194/gitlabhq,stoplightio/gitlabhq,jrjang/gitlab-ce,ttasanen/gitlabhq,t-zuehlsdorff/gitlabhq,dreampet/gitlab,iiet/iiet-git,szechyjs/gitlabhq,koreamic/gitlabhq,sonalkr132/gitlabhq,larryli/gitlabhq,joalmeid/gitlabhq,fpgentil/gitlabhq,axilleas/gitlabhq,larryli/gitlabhq,dreampet/gitlab,dplarson/gitlabhq,icedwater/gitlabhq,fpgentil/gitlabhq,mr-dxdy/gitlabhq,aaronsnyder/gitlabhq,yfaizal/gitlabhq,stoplightio/gitlabhq,louahola/gitlabhq,ferdinandrosario/gitlabhq,louahola/gitlabhq,ttasanen/gitlabhq,LUMC/gitlabhq,jrjang/gitlabhq,openwide-java/gitlabhq,jirutka/gitlabhq,duduribeiro/gitlabhq,jrjang/gitlabhq,gopeter/gitlabhq,stoplightio/gitlabhq,t-zuehlsdorff/gitlabhq,joalmeid/gitlabhq,screenpages/gitlabhq,szechyjs/gitlabhq,ksoichiro/gitlabhq,LUMC/gitlabhq,LUMC/gitlabhq,shinexiao/gitlabhq,darkrasid/gitlabhq,ksoichiro/gitlabhq,ttasanen/gitlabhq,dplarson/gitlabhq,Datacom/gitlabhq,larryli/gitlabhq,htve/GitlabForChinese,sonalkr132/gitlabhq,htve/GitlabForChinese,ikappas/gitlabhq,jrjang/gitlab-ce,Datacom/gitlabhq,daiyu/gitlab-zh,koreamic/gitlabhq,koreamic/gitlabhq,martijnvermaat/gitlabhq,allysonbarros/gitlabhq,dwrensha/gitlabhq,martijnvermaat/gitlabhq,allysonbarros/gitlabhq,SVArago/gitlabhq,duduribeiro/gitlabhq,yatish27/gitlabhq,cui-liqiang/gitlab-ce,mrb/gitlabhq,darkrasid/gitlabhq,openwide-java/gitlabhq,iiet/iiet-git,yfaizal/gitlabhq,duduribeiro/gitlabhq,daiyu/gitlab-zh,Telekom-PD/gitlabhq,Datacom/gitlabhq,jrjang/gitlabhq,t-zuehlsdorff/gitlabhq,szechyjs/gitlabhq,SVArago/gitlabhq,openwide-java/gitlabhq,salipro4ever/gitlabhq,axilleas/gitlabhq,iiet/iiet-git,ikappas/gitlabhq,MauriceMohlek/gitlabhq,Soullivaneuh/gitlabhq,darkrasid/gitlabhq,sue445/gitlabhq,mmkassem/gitlabhq,fscherwi/gitlabhq,Soullivaneuh/gitlabhq,jirutka/gitlabhq,mmkassem/gitlabhq,darkrasid/gitlabhq,larryli/gitlabhq,aaronsnyder/gitlabhq,salipro4ever/gitlabhq,icedwater/gitlabhq,t-zuehlsdorff/gitlabhq,dreampet/gitlab,ksoichiro/gitlabhq,fscherwi/gitlabhq,yfaizal/gitlabhq,mmkassem/gitlabhq,dwrensha/gitlabhq,daiyu/gitlab-zh,mrb/gitlabhq,htve/GitlabForChinese,jrjang/gitlab-ce,gopeter/gitlabhq,allysonbarros/gitlabhq,mr-dxdy/gitlabhq,gopeter/gitlabhq,sue445/gitlabhq,allysonbarros/gitlabhq,joalmeid/gitlabhq,Soullivaneuh/gitlabhq,yfaizal/gitlabhq,ksoichiro/gitlabhq,NKMR6194/gitlabhq,ttasanen/gitlabhq,Datacom/gitlabhq,cui-liqiang/gitlab-ce,jirutka/gitlabhq,louahola/gitlabhq,icedwater/gitlabhq,salipro4ever/gitlabhq,screenpages/gitlabhq,Telekom-PD/gitlabhq,stoplightio/gitlabhq,martijnvermaat/gitlabhq,aaronsnyder/gitlabhq,shinexiao/gitlabhq,Telekom-PD/gitlabhq,shinexiao/gitlabhq,aaronsnyder/gitlabhq,cui-liqiang/gitlab-ce,fpgentil/gitlabhq,icedwater/gitlabhq,ferdinandrosario/gitlabhq,yatish27/gitlabhq,ferdinandrosario/gitlabhq,Soullivaneuh/gitlabhq,iiet/iiet-git,ikappas/gitlabhq,sonalkr132/gitlabhq,szechyjs/gitlabhq,dreampet/gitlab,dwrensha/gitlabhq,Telekom-PD/gitlabhq,SVArago/gitlabhq,ikappas/gitlabhq