The dirpath may have the form "*.git/stuff".  Simplified it by removing the regex and just looking for ".git" in dirpath.