Sergey Vlasov [off-list ref] writes:
What name format should be used for such saved refs? refs/old/`date -I`
is not unique enough; probably `date --utc +%Y.%m.%d-%H.%M.%S`? And it
would be good if multiple refs which were deleted or modified in a
non-fast-forward way during a single operation (like git-mirror) would
be saved together - which may be tricky if they are saved at the lower
level (in update-ref).
Adding the fast-forward check into update-ref also does not look nice,
but this check is required for full safety.
I wasn't going to suggest doing the check or even naming at such
a low level. From the usability point of view, the caller
should decide if the discarded refs are even saved at all, and
if so in which namespace. That way commit_lock_file() can just
notice the old version of the locked file (it is always sitting
next to it) and hardlink the discarded one to the purgatory
before renaming the newly created .lock file there.