code: def _list_files(root):
      
  
      dir_patterns, file_patterns = _gitignore(root)
      paths = []
      prefix = os.path.abspath(root) + os.sep
      for base, dirs, files in os.walk(root):
          for d in dirs:
              for dir_pattern in dir_patterns:
                  if fnmatch(d, dir_pattern):
                      dirs.remove(d)
                      break
          for f in files:
              skip = False
              for file_pattern in file_patterns:
                  if fnmatch(f, file_pattern):
                      skip = True
                      break
              if skip:
                  continue
              full_path = os.path.join(base, f)
              if full_path[:len(prefix)] == prefix:
                  full_path = full_path[len(prefix):]
              paths.append(full_path)
      return sorted(paths)
docs: Lists all of the files in a directory, taking into account any .gitignore
      file that is present
  
      :param root:
          A unicode filesystem path
  
      :return:
          A list of unicode strings, containing paths of all files not ignored
          by .gitignore with root, using relative paths