MCPcopy Index your code
hub / github.com/go-git/go-git / RemoveGlob

Method RemoveGlob

worktree_status.go:681–709  ·  view source on GitHub ↗

RemoveGlob removes all paths, matching pattern, from the index. If pattern matches a directory path, all directory contents are removed from the index recursively.

(pattern string)

Source from the content-addressed store, hash-verified

679// matches a directory path, all directory contents are removed from the index
680// recursively.
681func (w *Worktree) RemoveGlob(pattern string) error {
682 idx, err := w.r.Storer.Index()
683 if err != nil {
684 return err
685 }
686
687 entries, err := idx.Glob(pattern)
688 if err != nil {
689 return err
690 }
691
692 for _, e := range entries {
693 file := filepath.FromSlash(e.Name)
694 if _, err := w.Filesystem.Lstat(file); err != nil && !os.IsNotExist(err) {
695 return err
696 }
697
698 if _, err := w.doRemoveFile(idx, file); err != nil {
699 return err
700 }
701
702 dir, _ := filepath.Split(file)
703 if err := w.removeEmptyDirectory(dir); err != nil {
704 return err
705 }
706 }
707
708 return w.r.Storer.SetIndex(idx)
709}
710
711// Move moves or rename a file in the worktree and the index, directories are
712// not supported.

Callers 3

TestRemoveGlobMethod · 0.95

Calls 6

doRemoveFileMethod · 0.95
removeEmptyDirectoryMethod · 0.95
GlobMethod · 0.80
IndexMethod · 0.65
SetIndexMethod · 0.65
LstatMethod · 0.45

Tested by 3

TestRemoveGlobMethod · 0.76