[fixup] repo: Add an internal struct to manage remotes

Fix a memory leak on error.