clone/update: optimize ref removal
The clone operation needs to remove any pre-existing refs before
restarting a clone and also any garbage git-svn refs after an svn
clone.
The update operation needs to remove any garbage git-svn refs after
an update and also unclean refs when switching to a clean mirror.
Calling update-ref once for each ref to be removed is slow and can
be terribly painful when thousands of refs are involved.
Instead use update-ref --stdin and process all the changes at once.
We do, however, provide a slow backwards compatibiliy function so that a
server that for some incomprehensible reason is not running at least Git
version 1.8.5 (when update-ref --stdin functionality was added) can
still operate properly.
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>