Make this work with bare git repos; fix the case where there are 0 refs/remotes/REMOTE-NAME