Skip to content

Ignore symbolic refs that point to deleted branches

Stan Hu requested to merge stanhu/gitlab_git:fix-invalid-symbolic-ref into master

While trying to test another bug, I deleted a branch that happened to have a symbolic ref pointing to it. I wasn't able to even reach the GitLab dashboard as a result. The error that showed up:

Rugged::ReferenceError - Reference 'refs/heads/new-branch' not found:
  gitlab_git (7.2.6) lib/gitlab_git/repository.rb:56:in `block in branches'
  gitlab_git (7.2.6) lib/gitlab_git/repository.rb:55:in `branches'
  gitlab_git (7.2.6) lib/gitlab_git/repository.rb:50:in `branch_names'
  gitlab_git (7.2.6) lib/gitlab_git/repository.rb:116:in `discover_default_branch'
  gitlab_git (7.2.6) lib/gitlab_git/repository.rb:33:in `initialize'
  app/models/repository.rb:11:in `initialize'
  app/models/project.rb:263:in `repository'
  app/models/project.rb:426:in `avatar_in_git'
  app/models/project.rb:435:in `avatar_url'
  app/helpers/application_helper.rb:41:in `project_icon'
  app/views/shared/_project.html.haml:5:in `block (2 levels) in _app_views_shared__project_html_haml__222087319794829046_70255909387840'
  haml (4.0.5) lib/haml/helpers.rb:368:in `block in capture_haml'
  haml (4.0.5) lib/haml/helpers.rb:608:in `with_haml_buffer'
  haml (4.0.5) lib/haml/helpers.rb:364:in `capture_haml'
  haml (4.0.5) lib/haml/helpers/xss_mods.rb:61:in `capture_haml_with_haml_xss'
  haml (4.0.5) lib/haml/helpers/action_view_mods.rb:45:in `capture_with_haml'

The repository had this state:

$ git branch -a
* master
  test
  test-symlink -> new-branch

Merge request reports