diff options
| author | Carlos MartÃn Nieto <[email protected]> | 2019-01-04 00:43:48 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-01-04 00:43:48 +0000 |
| commit | c27981c283b5e02fcbbf17cce0a3e6da9339986c (patch) | |
| tree | a86cb9a655d65e92503b71436dbc870be383a2db /index.go | |
| parent | c740e1d83df805f55eda80c76bd1f1c562b3051d (diff) | |
| parent | dd973b99ad050eae73c3cc3deac162e797c6f530 (diff) | |
Merge pull request #463 from Nivl/patch-1
Add index.Clear() to clear the index object
Diffstat (limited to 'index.go')
| -rw-r--r-- | index.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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 { |
