Skip to content

Remove unnecessary validation from default branch updates with WAL

Sami Hiltunen requested to merge smh-default-branch-fix into master

The TransactionManager is currently performing some extra validation on default branch updates. Namely, it checks that the reference HEAD is being pointed to exists. This deviates from the non-WAL behavior which updates the HEAD to point to the reference regardless of its existence. This is also a problematic consistency guarantee to uphold. When repository is created, HEAD points to refs/heads/main but the branch doesn't necessarily exist meaning the starting state is already violating the consistency guarantee the updates attempt to uphold. More over, there's nothing preventing deleting the reference that is pointed to by HEAD. Other application code also already has to handle the case when reference pointed to by HEAD doesn't exist.

Given these consistency guarantees are not upheld, and they are not needed, this MR removes the checks. The default branch is updated as long as the reference format is valid.

The MR also improves the tests by asserting the actual state of HEAD. The default branch update application logic was also simplified.

Closes #4822 (closed)

Edited by Sami Hiltunen

Merge request reports