summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelvin <[email protected]>2018-10-25 15:13:32 -0700
committerMelvin Laplanche <[email protected]>2018-10-25 15:52:43 -0700
commitdd973b99ad050eae73c3cc3deac162e797c6f530 (patch)
tree914e8fd99b0cdd59964c0da1f83ae94b11477ce7
parenteec1547c20617534ad9e825673bf78e355dda7d9 (diff)
Add index.Clear() to clear the index object
-rw-r--r--index.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/index.go b/index.go
index 5106516..dd13460 100644
--- a/index.go
+++ b/index.go
@@ -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 {