code: def hash_dir(path):
      
      dir_hash = {}
  
      for root, dirs, files in os.walk(path, topdown=False):
          f_hash = ((f, hash_file(join(root, f))) for f in files)
          d_hash = ((d, dir_hash[join(root, d)]) for d in dirs)
          # split+join normalizes paths on Windows (note the imports)
          dir_hash[join(*split(root))] = _mktree(f_hash, d_hash)
  
      return dir_hash[path]
docs: Write directory at path to Git index, return its SHA1 as a string.