repository: clarify assignment and test order
index: fix potential memory leaks
pack: fix memory leak in error path
Fix some more memory leaks in error path
Merge pull request #1728 from ivoire/small_fixes

Small fixes