Merge pull request #1573 from nulltoken/fix/leaks

Fix some memory leaks
refdb: Change write() to accept a flatten reference
refdb: Change delete() to accept a reference name
refs: Enforce reference deletion test coverage

Also fix a uninitialized variable runtime issue.
refs: Introduce git_reference_delete_byname()
Fix MSVC compilation warning