code: def add_directories(names):
      
      res = list(names)
      seen = set(names)
      for name in names:
          while True:
              name = os.path.dirname(name)
              if not name or name in seen:
                  break
              res.append(name)
              seen.add(name)
      return sorted(res)
docs: Git/Mercurial/zip files omit directories, let's add them back.