MCPcopy Create free account
hub / github.com/libgit2/git2go / Apply

Method Apply

stash.go:217–234  ·  view source on GitHub ↗

Apply applies a single stashed state from the stash list. If local changes in the working directory conflict with changes in the stash then ErrorCodeConflict will be returned. In this case, the index will always remain unmodified and all files in the working directory will remain unmodified. Howe

(index int, opts StashApplyOptions)

Source from the content-addressed store, hash-verified

215//
216// Error codes can be interogated with IsErrorCode(err, ErrorCodeNotFound).
217func (c *StashCollection) Apply(index int, opts StashApplyOptions) error {
218 var err error
219 optsC := populateStashApplyOptions(&C.git_stash_apply_options{}, &opts, &err)
220 defer freeStashApplyOptions(optsC)
221
222 runtime.LockOSThread()
223 defer runtime.UnlockOSThread()
224
225 ret := C.git_stash_apply(c.repo.ptr, C.size_t(index), optsC)
226 runtime.KeepAlive(c)
227 if ret == C.int(ErrorCodeUser) && err != nil {
228 return err
229 }
230 if ret < 0 {
231 return MakeGitError(ret)
232 }
233 return nil
234}
235
236// StashCallback is called per entry when interating over all
237// the stashed states.

Callers 1

TestStashFunction · 0.80

Calls 3

freeStashApplyOptionsFunction · 0.85
MakeGitErrorFunction · 0.85

Tested by 1

TestStashFunction · 0.64