This would be slow on large repositories, as we're recompiling for every path; it also means files name "foo.git: would be included. 

Perhaps it's possible to use elem[1] to check for the control directory; e.g. by checking if it starts with repo.control_dir().