refs: conditional ref updates

Allow updating references if the old value matches the given one.

Missing pieces:
- [x] Conditional deletes
- [x] Conditional updates for symrefs