updateref: Fix not detecting invalid ref names on pipe failure
Our pipelines started to flake recently in the updateref package with the following error:
updateref_test.go:181:
Error Trace: /builds/gitlab-org/gitaly/internal/git/updateref/updateref_test.go:181
Error: Not equal:
expected: updateref.ErrInvalidReferenceFormat(updateref.ErrInvalidReferenceFormat{ReferenceName:"refs/heads\\master"})
actual : *fmt.wrapError(&fmt.wrapError{msg:"updating state to \"prepare\": write |1: broken pipe: \"fatal: invalid ref format: refs/heads\\\\master\\n\"", err:(*fmt.wrapError)(0xc000bae080)})
Test: TestUpdater_invalidReferenceName
The root cause of this seems to be a race with writing to the git-update-ref(1) process and the process dying, where if we lose the race we don't properly process the standard error.
Fix the bug by also checking stderr for invalid reference format errors when writing to the process fails.
Changelog: fixed