commit.c: allow lookup_commit_reference to handle arbitrary repositories