code: def find_worktree_git_dir(dotgit):
      
      try:
          statbuf = os.stat(dotgit)
      except OSError:
          return None
      if not stat.S_ISREG(statbuf.st_mode):
          return None
  
      try:
          lines = open(dotgit, 'r').readlines()
          for key, value in [line.strip().split(': ') for line in lines]:
              if key == 'gitdir':
                  return value
      except ValueError:
          pass
      return None
docs: Search for a gitdir for this worktree.