Fix crash when committing after switching repositories

Fixes #1