Error 500 when creating merge request due to refs/tmp/XXX not found
Created by @stanhu.
I attempted to create a new merge request in CE and change the target branch from master, but I got an Error 500.
/cc: @godfat
https://sentry.gitlap.com/gitlab/gitlabcom/issues/39761/
NoMethodError: undefined method `sha' for nil:NilClass
app/models/repository.rb:1052:in `with_repo_branch_commit'
start_repository.commit(start_branch_name).sha
lib/gitlab/metrics/instrumentation.rb:156:in `block in with_repo_branch_commit'
trans.method_call_for(#{label.to_sym.inspect}).measure { super }
lib/gitlab/metrics/method_call.rb:23:in `measure'
retval = yield
lib/gitlab/metrics/instrumentation.rb:156:in `with_repo_branch_commit'
trans.method_call_for(#{label.to_sym.inspect}).measure { super }
app/services/compare_service.rb:15:in `execute'
target_project.repository.with_repo_branch_commit(
...
(125 additional frame(s) were not displayed)
Rugged::ReferenceError: Reference 'refs/tmp/942155a23399fcc1d35f06fd1cd7979b/head' not found
app/models/repository.rb:1058:in `delete'
rugged.references.delete(tmp_ref) if tmp_ref
app/models/repository.rb:1058:in `ensure in with_repo_branch_commit'
rugged.references.delete(tmp_ref) if tmp_ref
app/models/repository.rb:1058:in `with_repo_branch_commit'
rugged.references.delete(tmp_ref) if tmp_ref
lib/gitlab/metrics/instrumentation.rb:156:in `block in with_repo_branch_commit'
trans.method_call_for(#{label.to_sym.inspect}).measure { super }
lib/gitlab/metrics/method_call.rb:23:in `measure'
retval = yield
...
(127 additional frame(s) were not displayed)
Rugged::ReferenceError: Reference 'refs/tmp/942155a23399fcc1d35f06fd1cd7979b/head' not found