Skip to content

Commit

Permalink
Merge pull request libgit2#463 from Nivl/patch-1
Browse files Browse the repository at this point in the history
Add index.Clear() to clear the index object
  • Loading branch information
carlosmn authored Jan 4, 2019
2 parents c740e1d + dd973b9 commit c27981c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions index.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ func (v *Index) Path() string {
return ret
}

// Clear clears the index object in memory; changes must be explicitly
// written to disk for them to take effect persistently
func (v *Index) Clear() error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()

err := C.git_index_clear(v.ptr)
runtime.KeepAlive(v)
if err < 0 {
return MakeGitError(err)
}
return nil
}

// Add adds or replaces the given entry to the index, making a copy of
// the data
func (v *Index) Add(entry *IndexEntry) error {
Expand Down

0 comments on commit c27981c

Please sign in to comment.