cache: convert get_graft_file to handle arbitrary repositories