code: func (w *Worktree) Add(path string) (plumbing.Hash, error) {
  	// TODO(mcuadros): remove plumbing.Hash from signature at v5.
  	s, err := w.Status()
  	if err != nil {
  		return plumbing.ZeroHash, err
  	}
  
  	idx, err := w.r.Storer.Index()
  	if err != nil {
  		return plumbing.ZeroHash, err
  	}
  
  	var h plumbing.Hash
  	var added bool
  
  	fi, err := w.Filesystem.Lstat(path)
  	if err != nil || !fi.IsDir() {
  		added, h, err = w.doAddFile(idx, s, path)
  	} else {
  		added, err = w.doAddDirectory(idx, s, path)
  	}
  
  	if err != nil {
  		return h, err
  	}
  
  	if !added {
  		return h, nil
  	}
  
  	return h, w.r.Storer.SetIndex(idx)
  }
docs: // Add adds the file contents of a file in the worktree to the index. if the
  // file is already staged in the index no error is returned. If a file deleted
  // from the Workspace is given, the file is removed from the index. If a
  // directory given, adds the files and all his sub-directories recursively in
  // the worktree to the index. If any of the files is already staged in the index
  // no error is returned. When path is a file, the blob.Hash is returned.