commit.c: allow lookup_commit_reference_gently to handle arbitrary repositories