git: Match packed-refs name conflicts in the files backend regex
What does this MR do?
Makes the files-backend ReferenceExistsConflictRegex accept git's file/directory conflict message both with and without the cannot lock ref '…': prefix, so updateref.Updater returns a FileDirectoryConflictError (with existing_reference / conflicting_reference metadata) instead of the bare exit status 128.
Why
git update-ref --stdin reports a name conflict in two shapes. When the conflict is found while locking the loose reference, lock_ref_for_update wraps it as cannot lock ref 'x': 'a' exists; cannot create 'a/b'. When the reference does not exist yet, the files backend defers the check and runs it against packed-refs in files_transaction_prepare, and that path prints only 'a' exists; cannot create 'a/b'. Deleting a reference that does not exist goes through the second path too.
Gitaly's files regex only matched the first shape (the reftable one has accepted the bare shape since 259ba0e8), so parseStderr() returned nil and callers such as DeleteRefs surfaced Internal: unable to prepare: exit status 128, with the actual message only in error_metadata.stderr.
On GitLab.com two repositories on two production nodes have been producing ~17,800 such DeleteRefs/Internal errors a day since 2026-09-25: each has a stray packed refs/merge-requests/<iid> reference, and a Sidekiq worker keeps asking to delete the non-existent refs/merge-requests/<iid>/head. The error text gave operators nothing to act on for eleven days. Tracker (confidential, GitLab-internal): https://gitlab.com/gitlab-com/gl-infra/sandbox/gitaly-sre-flow/-/issues/1. Runbook: gitlab-com/runbooks!11733.
Test
TestUpdater_fileDirectoryConflictWithPackedReference creates refs/heads/directory, runs git pack-refs --all, then deletes the missing refs/heads/directory/file through Prepare() and Commit(). Without the regex change it fails on the files backend with the production message shape:
expected: FileDirectoryConflictError{ConflictingReferenceName:"refs/heads/directory/file", ExistingReferenceName:"refs/heads/directory"}
actual : structerr.Error{… metadata: stderr: "fatal: prepare: 'refs/heads/directory' exists; cannot create 'refs/heads/directory/file'\n" …}With it, TEST_PACKAGES=./internal/git/updateref make test-go (66 tests) and make test-with-reftable (the F/D tests) pass.
Not in this MR
DeleteRefsstill returnsInternalfor aFileDirectoryConflictError; whether a repository-state conflict should be a different code is a separate question.DeleteRefsmapsErrPackedRefsLocked(transient contention) toInternalrather thanAborted; tracked separately in the same tracker (#42 (closed)).