diff options
Diffstat (limited to 'plumbing/format/index/index.go')
-rw-r--r-- | plumbing/format/index/index.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/plumbing/format/index/index.go b/plumbing/format/index/index.go index 782e3d1..9de4230 100644 --- a/plumbing/format/index/index.go +++ b/plumbing/format/index/index.go @@ -62,6 +62,18 @@ func (i *Index) Entry(path string) (*Entry, error) { return nil, ErrEntryNotFound } +// Remove remove the entry that match the give path and returns deleted entry. +func (i *Index) Remove(path string) (*Entry, error) { + for index, e := range i.Entries { + if e.Name == path { + i.Entries = append(i.Entries[:index], i.Entries[index+1:]...) + return e, nil + } + } + + return nil, ErrEntryNotFound +} + // String is equivalent to `git ls-files --stage --debug` func (i *Index) String() string { buf := bytes.NewBuffer(nil) |