Don't touch ref files manually
Messing with files manually doesn't work if the refs are packed. The
officially preferred way is to use git-update-ref, git-show-ref,
et.al. So do that.
As a consequence of this, we have some small behavior changes:
* We used to not leave empty directories behind in the refs tree.
But now that's all in the hands of git-update-ref, which does
leave them behind. Tests that assumed the old behavior have been
fixed.
* We (that is, git-show-ref) no longer distinguish between a ref
that doesn't exist and a ref that contains garbage. So the tests
that assumed we'd fail when encountering a spurious ref with
garbage in it have had to go through attitude readjustment.
Signed-off-by: Karl Hasselström <kha@treskal.com>